﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using System.Xml;
using System.IO;
using XML.Ultils;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraEditors;

namespace XML
{
    public partial class MainForm : RibbonForm
    {
        Ultil ul = new Ultil();
        Validate val = new Validate();
        MessageBox message = new MessageBox();
        static string fileRecipes = "xml/recipes.xml";
        FileStream fsRecipes;

        static string fileFermentables = "xml/grain.xml";
        FileStream fsFermentables;

        static string fileHops = "xml/hops.xml";
        FileStream fsHops;

        static string fileStyle = "xml/style.xml";
        FileStream fsStyle;

        static string fileEquipment = "xml/equipment.xml";
        FileStream fsEquipment;

        static string fileMisc = "xml/misc.xml";
        FileStream fsMisc;

        static string fileYeast = "xml/yeast.xml";
        FileStream fsYeast;

        static string fileMash = "xml/mash.xml";
        FileStream fsMash;

        XmlDocument documentRecipe = new XmlDocument();
        XmlDocument documentStyle = new XmlDocument();
        XmlDocument documentEquipment = new XmlDocument();
        XmlDocument documentFermentable = new XmlDocument();
        XmlDocument documentHop = new XmlDocument();
        XmlDocument documentMics = new XmlDocument();
        XmlDocument documentYeast = new XmlDocument();
        XmlDocument documentMash = new XmlDocument();

        DataTable dtFermentable = new DataTable();
        DataTable dtHop = new DataTable();
        DataTable dtMisc = new DataTable();
        DataTable dtYeast = new DataTable();

        private Timer timer1;
        private int hour1 = 0;
        private int min1 = 0;
        private int second1 = 0;
        private Timer timer2;
        private int hour2 = 0;
        private int min2 = 0;
        private int second2 = 0;

        public MainForm()
        {
            InitializeComponent();
            InitSkinGallery();
            Init();

            //Recipe
            fsRecipes = new FileStream(fileRecipes, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/recipes.xsd", fsRecipes);
            fsRecipes.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                //Load xml file
                fsRecipes = new FileStream(fileRecipes, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentRecipe.Load(fsRecipes);
                try
                {
                    splashScreenManager.ShowWaitForm();
                }
                catch (Exception) { }
                tableViewRecipes.GridControl.DataSource = ul.dataTableRecipes(ul.ListRecipes(documentRecipe));
                try
                {
                    splashScreenManager.CloseWaitForm();
                }
                catch (Exception) { }
            }

            //Style
            fsStyle = new FileStream(fileStyle, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/style.xsd", fsStyle);
            fsStyle.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsStyle = new FileStream(fileStyle, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentStyle.Load(fsStyle);

                
            }
            //Equipment
            fsEquipment = new FileStream(fileEquipment, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/equipment.xsd", fsEquipment);
            fsEquipment.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsEquipment = new FileStream(fileEquipment, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentEquipment.Load(fsEquipment);
            }

            //Fermentable
            fsFermentables = new FileStream(fileFermentables, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/grain.xsd", fsFermentables);
            fsFermentables.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsFermentables = new FileStream(fileFermentables, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentFermentable.Load(fsFermentables);
            }

            //Hop
            fsHops = new FileStream(fileHops, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/hops.xsd", fsHops);
            fsHops.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsHops = new FileStream(fileHops, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentHop.Load(fsHops);
            }
            //Misc
            fsMisc = new FileStream(fileMisc, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/misc.xsd", fsMisc);
            fsMisc.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsMisc = new FileStream(fileMisc, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentMics.Load(fsMisc);
            }
            //Yeast
            fsYeast = new FileStream(fileYeast, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/yeast.xsd", fsYeast);
            fsYeast.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsYeast = new FileStream(fileYeast, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentYeast.Load(fsYeast);
            }
            //Mash
            fsMash = new FileStream(fileMash, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
            val.validates("xml/mash.xsd", fsMash);
            fsMash.Close();
            if (val.Check)
            {
                message.title = "Notice";
                message.Content = "Xml file is not validated";
                message.ShowDialog();
            }
            else
            {
                fsMash = new FileStream(fileMash, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                documentMash.Load(fsMash);
            }
            loadIngredient();
        }
        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }
        BindingList<Person> gridDataList = new BindingList<Person>();
        void Init()
        {
           
            timer1 = new Timer();
            timer1.Interval = 1000;
            this.timer1.Tick += new EventHandler(timer1_tick);
            timer2 = new Timer();
            timer2.Interval = 1000;
            this.timer2.Tick += new EventHandler(timer2_tick);
        }

        public void loadRecipes()
        {
            tableViewRecipes.GridControl.DataSource = ul.dataTableRecipes(ul.ListRecipes(documentRecipe));
        }

        public void loadStyles()
        {
            tableViewStyles.GridControl.DataSource = ul.dataTableStyles(ul.ListStyles(documentStyle));
        }

        public void loadEquipment()
        {
            tableViewEquipment.GridControl.DataSource = ul.dataTableEquipments(ul.ListEquipments(documentEquipment));
        }

        public void loadFermentables()
        {
            tableViewFermentable.GridControl.DataSource = ul.dataTableFermentables(ul.ListFermentables(documentFermentable));
           
        }

        public void loadHops()
        {
            tableViewHop.GridControl.DataSource = ul.dataTableHops(ul.ListHops(documentHop));
        }

        public void loadMiscs()
        {
            tableViewMisc.GridControl.DataSource = ul.dataTableMiscs(ul.ListMiscs(documentMics));
        }

        public void loadYeasts()
        {
            tableViewYeasts.GridControl.DataSource = ul.dataTableYeasts(ul.ListYeasts(documentYeast));
        }

        public void loadMashs()
        {
            tableviewMash.GridControl.DataSource = ul.dataTableMash(ul.ListMashs(documentMash));
        }

        public void loadIngredient()
        {
            //Fermentable
            tableFermentablesRecipes.DataSource = dtFermentable;
            dtFermentable.Columns.Add("name", typeof(string));
            dtFermentable.Columns.Add("version", typeof(string));
            dtFermentable.Columns.Add("type", typeof(string));
            dtFermentable.Columns.Add("amount", typeof(string));
            dtFermentable.Columns.Add("yield", typeof(string));
            dtFermentable.Columns.Add("color", typeof(string));
            dtFermentable.Columns.Add("add_after_boil", typeof(string));
            dtFermentable.Columns.Add("origin", typeof(string));
            dtFermentable.Columns.Add("supplier", typeof(string));
            dtFermentable.Columns.Add("notes", typeof(string));
            dtFermentable.Columns.Add("coarse_fine_diff", typeof(string));
            dtFermentable.Columns.Add("moisture", typeof(string));
            dtFermentable.Columns.Add("diastatic_power", typeof(string));
            dtFermentable.Columns.Add("protein", typeof(string));
            dtFermentable.Columns.Add("max_in_batch", typeof(string));
            dtFermentable.Columns.Add("recommend_mash", typeof(string));
            dtFermentable.Columns.Add("ibu_gal_per_lb", typeof(string));
            dtFermentable.Columns.Add("display_amount", typeof(string));
            dtFermentable.Columns.Add("inventory", typeof(string));
            dtFermentable.Columns.Add("potential", typeof(string));
            dtFermentable.Columns.Add("display_color", typeof(string));

            cbbFermentablesRecipes.DataSource = ul.dataTableFermentables(ul.ListFermentables(documentFermentable));
            cbbFermentablesRecipes.PopulateColumns();
            cbbFermentablesRecipes.DisplayMember = "name";
            cbbFermentablesRecipes.ValueMember = "name";
            cbbFermentablesRecipes.Columns["version"].Visible = false;
            cbbFermentablesRecipes.Columns["type"].Visible = false;
            cbbFermentablesRecipes.Columns["amount"].Visible = false;
            cbbFermentablesRecipes.Columns["yield"].Visible = false;
            cbbFermentablesRecipes.Columns["color"].Visible = false;
            cbbFermentablesRecipes.Columns["add_after_boil"].Visible = false;
            cbbFermentablesRecipes.Columns["origin"].Visible = false;
            cbbFermentablesRecipes.Columns["supplier"].Visible = false;
            cbbFermentablesRecipes.Columns["notes"].Visible = false;
            cbbFermentablesRecipes.Columns["coarse_fine_diff"].Visible = false;
            cbbFermentablesRecipes.Columns["moisture"].Visible = false;
            cbbFermentablesRecipes.Columns["diastatic_power"].Visible = false;
            cbbFermentablesRecipes.Columns["protein"].Visible = false;
            cbbFermentablesRecipes.Columns["max_in_batch"].Visible = false;
            cbbFermentablesRecipes.Columns["recommend_mash"].Visible = false;
            cbbFermentablesRecipes.Columns["ibu_gal_per_lb"].Visible = false;
            cbbFermentablesRecipes.Columns["display_amount"].Visible = false;
            cbbFermentablesRecipes.Columns["inventory"].Visible = false;
            cbbFermentablesRecipes.Columns["potential"].Visible = false;
            cbbFermentablesRecipes.Columns["display_color"].Visible = false;

            cbbFermentablesRecipes.EditValueChanged += (object sender, EventArgs e) =>
            {
                string name = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("name").ToString();
                string version = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("version").ToString();
                string type = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                string amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount").ToString();
                string yield = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("yield").ToString();
                string colorSRM = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("color").ToString();
                string add_after_boil = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("add_after_boil").ToString();
                string origin = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("origin").ToString();
                string supplier = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("supplier").ToString();
                string notes = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("notes").ToString();
                string coarse_fine_diff = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("coarse_fine_diff").ToString();
                string moisture = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("moisture").ToString();
                string diastatic_power = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("diastatic_power").ToString();
                string protein = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("protein").ToString();
                string max_in_batch = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("max_in_batch").ToString();
                string recommend_mash = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("recommend_mash").ToString();
                string ibu_gal_per_lb = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("ibu_gal_per_lb").ToString();
                string display_amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_amount").ToString();
                string inventory = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("inventory").ToString();
                string potential = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("potential").ToString();
                string display_color = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_color").ToString();
                //string display_amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_amount").ToString();

                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[0], name);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[1], version);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[2], type);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[3], amount);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[4], yield);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[5], colorSRM);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[6], add_after_boil);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[7], origin);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[8], supplier);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[9], notes);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[10], coarse_fine_diff);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[11], moisture);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[12], diastatic_power);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[13], protein);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[14], max_in_batch);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[15], recommend_mash);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[16], ibu_gal_per_lb);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[17], display_amount);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[18], inventory);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[19], potential);
                tableViewFermentablesRecipes.SetRowCellValue(tableViewFermentablesRecipes.FocusedRowHandle, tableViewFermentablesRecipes.Columns[20], display_color);

                tableFermentablesRecipes.Refresh();

                float batch_size = 0;
                try
                {
                    batch_size = float.Parse(txtTargetBatchSizeRecipes.Text.Replace("L",""));
                }
                catch (Exception) { }
                float total = 0;
                float srm = 0;
                float x1 = 1.49F;
                float x2 = 0.69F;
                for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
                {
                    float mcu = 1;
                    string amount_display = "";
                    float amount_row = 0;
                    float color_display = 0;
                    try
                    {
                        amount_display = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();
                        amount_row = float.Parse(amount_display.Replace("lb", ""));
                    }
                    catch (Exception) { }
                    try
                    {
                        color_display = float.Parse(tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString());
                    }
                    catch (Exception) { }
                    mcu = (amount_row * color_display) / batch_size;
                    total = total + mcu;
                }
                srm = x1 * (total * x2);
                lbColorRecipes.Text = srm + " SRM";
                float color = srm;
                if (color >= 0 && color < 1)
                {
                    pictureRecipe.Image = Properties.Resources.SRM0;
                }
                else if (color >= 1 && color < 2)
                {
                    pictureRecipe.Image = Properties.Resources.SRM1;
                }
                else if (color >= 2 && color < 3)
                {
                    pictureRecipe.Image = Properties.Resources.SRM2;
                }
                else if (color >= 3 && color < 4)
                {
                    pictureRecipe.Image = Properties.Resources.SRM3;
                }
                else if (color >= 4 && color < 5)
                {
                    pictureRecipe.Image = Properties.Resources.SRM4;
                }
                else if (color >= 5 && color < 6)
                {
                    pictureRecipe.Image = Properties.Resources.SRM5;
                }
                else if (color >= 6 && color < 7)
                {
                    pictureRecipe.Image = Properties.Resources.SRM6;
                }
                else if (color >= 7 && color < 8)
                {
                    pictureRecipe.Image = Properties.Resources.SRM7;
                }
                else if (color >= 8 && color < 9)
                {
                    pictureRecipe.Image = Properties.Resources.SRM8;
                }
                else if (color >= 9 && color < 10)
                {
                    pictureRecipe.Image = Properties.Resources.SRM9;
                }
                else if (color >= 10 && color < 11)
                {
                    pictureRecipe.Image = Properties.Resources.SRM10;
                }
                else if (color >= 11 && color < 12)
                {
                    pictureRecipe.Image = Properties.Resources.SRM11;
                }
                else if (color >= 12 && color < 13)
                {
                    pictureRecipe.Image = Properties.Resources.SRM12;
                }
                else if (color >= 13 && color < 14)
                {
                    pictureRecipe.Image = Properties.Resources.SRM13;
                }
                else if (color >= 14 && color < 15)
                {
                    pictureRecipe.Image = Properties.Resources.SRM14;
                }
                else if (color >= 15 && color < 16)
                {
                    pictureRecipe.Image = Properties.Resources.SRM15;
                }
                else if (color >= 16 && color < 17)
                {
                    pictureRecipe.Image = Properties.Resources.SRM16;
                }
                else if (color >= 17 && color < 18)
                {
                    pictureRecipe.Image = Properties.Resources.SRM17;
                }
                else if (color >= 18 && color < 19)
                {
                    pictureRecipe.Image = Properties.Resources.SRM18;
                }
                else if (color >= 19 && color < 20)
                {
                    pictureRecipe.Image = Properties.Resources.SRM19;
                }
                else if (color >= 20 && color < 21)
                {
                    pictureRecipe.Image = Properties.Resources.SRM20;
                }
                else if (color >= 21 && color < 22)
                {
                    pictureRecipe.Image = Properties.Resources.SRM21;
                }
                else if (color >= 22 && color < 23)
                {
                    pictureRecipe.Image = Properties.Resources.SRM22;
                }
                else if (color >= 23 && color < 24)
                {
                    pictureRecipe.Image = Properties.Resources.SRM23;
                }
                else if (color >= 24 && color < 25)
                {
                    pictureRecipe.Image = Properties.Resources.SRM24;
                }
                else if (color >= 25 && color < 26)
                {
                    pictureRecipe.Image = Properties.Resources.SRM25;
                }
                else if (color >= 26 && color < 27)
                {
                    pictureRecipe.Image = Properties.Resources.SRM26;
                }
                else if (color >= 27 && color < 28)
                {
                    pictureRecipe.Image = Properties.Resources.SRM27;
                }
                else if (color >= 28 && color < 29)
                {
                    pictureRecipe.Image = Properties.Resources.SRM28;
                }
                else if (color >= 29 && color < 30)
                {
                    pictureRecipe.Image = Properties.Resources.SRM29;
                }
                else if (color >= 30 && color < 31)
                {
                    pictureRecipe.Image = Properties.Resources.SRM30;
                }
                else if (color >= 31 && color < 32)
                {
                    pictureRecipe.Image = Properties.Resources.SRM31;
                }
                else if (color >= 32 && color < 33)
                {
                    pictureRecipe.Image = Properties.Resources.SRM32;
                }
                else if (color >= 33 && color < 34)
                {
                    pictureRecipe.Image = Properties.Resources.SRM33;
                }
                else if (color >= 34 && color < 35)
                {
                    pictureRecipe.Image = Properties.Resources.SRM34;
                }
                else if (color >= 35 && color < 36)
                {
                    pictureRecipe.Image = Properties.Resources.SRM35;
                }
                else if (color >= 36)
                {
                    pictureRecipe.Image = Properties.Resources.SRM36;
                }

            };

            //Hops
            tableHopsRecipes.DataSource = dtHop;
            dtHop.Columns.Add("name", typeof(string));
            dtHop.Columns.Add("version", typeof(string));
            dtHop.Columns.Add("origin", typeof(string));
            dtHop.Columns.Add("alpha", typeof(string));
            dtHop.Columns.Add("amount", typeof(string));
            dtHop.Columns.Add("use", typeof(string));
            dtHop.Columns.Add("time", typeof(string));
            dtHop.Columns.Add("notes", typeof(string));
            dtHop.Columns.Add("type", typeof(string));
            dtHop.Columns.Add("form", typeof(string));
            dtHop.Columns.Add("beta", typeof(string));
            dtHop.Columns.Add("hsi", typeof(string));
            dtHop.Columns.Add("display_amount", typeof(string));
            dtHop.Columns.Add("inventory", typeof(string));
            dtHop.Columns.Add("display_time", typeof(string));

            cbbHopRecipes.DataSource = ul.dataTableHops(ul.ListHops(documentHop));
            cbbHopRecipes.PopulateColumns();
            cbbHopRecipes.DisplayMember = "name";
            cbbHopRecipes.ValueMember = "name";
            cbbHopRecipes.Columns["version"].Visible = false;
            cbbHopRecipes.Columns["origin"].Visible = false;
            cbbHopRecipes.Columns["alpha"].Visible = false;
            cbbHopRecipes.Columns["amount"].Visible = false;
            cbbHopRecipes.Columns["use"].Visible = false;
            cbbHopRecipes.Columns["time"].Visible = false;
            cbbHopRecipes.Columns["notes"].Visible = false;
            cbbHopRecipes.Columns["type"].Visible = false;
            cbbHopRecipes.Columns["form"].Visible = false;
            cbbHopRecipes.Columns["beta"].Visible = false;
            cbbHopRecipes.Columns["hsi"].Visible = false;
            cbbHopRecipes.Columns["display_amount"].Visible = false;
            cbbHopRecipes.Columns["inventory"].Visible = false;
            cbbHopRecipes.Columns["display_time"].Visible = false;

            cbbHopRecipes.EditValueChanged += (object sender, EventArgs e) =>
            {
                string name = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("name").ToString();
                string version = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("version").ToString();
                string origin = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("origin").ToString();
                string alpha = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("alpha").ToString();
                string amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount").ToString();
                string use = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("use").ToString();
                string time = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("time").ToString();
                string notes = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("notes").ToString();
                string type = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                string form = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("form").ToString();
                string beta = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("beta").ToString();
                string hsi = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("hsi").ToString();
                string display_amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_amount").ToString();
                string inventory = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("inventory").ToString();
                string display_time = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_time").ToString();

                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[0], name);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[1], version);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[2], origin);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[3], alpha);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[4], amount);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[5], use);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[6], time);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[7], notes);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[8], type);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[9], form);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[10], beta);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[11], hsi);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[12], display_amount);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[13], inventory);
                tableViewHopsRecipes.SetRowCellValue(tableViewHopsRecipes.FocusedRowHandle, tableViewHopsRecipes.Columns[14], display_time);
                
                tableHopsRecipes.Refresh();
            };

            //Miscs
            tableMiscsRecipes.DataSource = dtMisc;
            dtMisc.Columns.Add("name", typeof(string));
            dtMisc.Columns.Add("version", typeof(string));
            dtMisc.Columns.Add("type", typeof(string));
            dtMisc.Columns.Add("use", typeof(string));
            dtMisc.Columns.Add("amount", typeof(string));
            dtMisc.Columns.Add("time", typeof(string));
            dtMisc.Columns.Add("amount_is_weight", typeof(string));
            dtMisc.Columns.Add("use_for", typeof(string));
            dtMisc.Columns.Add("notes", typeof(string));
            dtMisc.Columns.Add("display_amount", typeof(string));
            dtMisc.Columns.Add("inventory", typeof(string));
            dtMisc.Columns.Add("display_time", typeof(string));

            cbbMiscRecipes.DataSource = ul.dataTableMiscs(ul.ListMiscs(documentMics));
            cbbMiscRecipes.PopulateColumns();
            cbbMiscRecipes.DisplayMember = "name";
            cbbMiscRecipes.ValueMember = "name";
            cbbMiscRecipes.Columns["version"].Visible = false;
            cbbMiscRecipes.Columns["type"].Visible = false;
            cbbMiscRecipes.Columns["use"].Visible = false;
            cbbMiscRecipes.Columns["amount"].Visible = false;
            cbbMiscRecipes.Columns["time"].Visible = false;
            cbbMiscRecipes.Columns["amount_is_weight"].Visible = false;
            cbbMiscRecipes.Columns["use_for"].Visible = false;
            cbbMiscRecipes.Columns["notes"].Visible = false;
            cbbMiscRecipes.Columns["display_amount"].Visible = false;
            cbbMiscRecipes.Columns["inventory"].Visible = false;
            cbbMiscRecipes.Columns["display_time"].Visible = false;

            cbbMiscRecipes.EditValueChanged += (object sender, EventArgs e) =>
            {
                string name = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("name").ToString();
                string version = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("version").ToString();
                string type = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                string use = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("use").ToString();
                string amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount").ToString();
                string amount_is_weight = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount_is_weight").ToString();
                string use_for = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("use_for").ToString();
                string notes = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("notes").ToString();
                string display_amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_amount").ToString();
                string inventory = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("inventory").ToString();
                string display_time = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_time").ToString();

                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[0], name);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[1], version);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[2], type);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[3], use);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[4], amount);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[5], amount_is_weight);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[6], use_for);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[7], notes);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[8], display_amount);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[9], inventory);
                tableViewMiscRecipes.SetRowCellValue(tableViewMiscRecipes.FocusedRowHandle, tableViewMiscRecipes.Columns[10], display_time);
                tableMiscsRecipes.Refresh();
            };

            //Yeast
            tableYeastsRecipes.DataSource = dtYeast;
            dtYeast.Columns.Add("name", typeof(string));
            dtYeast.Columns.Add("version", typeof(string));
            dtYeast.Columns.Add("type", typeof(string));
            dtYeast.Columns.Add("form", typeof(string));
            dtYeast.Columns.Add("amount", typeof(string));
            dtYeast.Columns.Add("amount_is_weight", typeof(string));
            dtYeast.Columns.Add("laboratory", typeof(string));
            dtYeast.Columns.Add("product_id", typeof(string));
            dtYeast.Columns.Add("min_temperature", typeof(string));
            dtYeast.Columns.Add("max_temperature", typeof(string));
            dtYeast.Columns.Add("flocculation", typeof(string));
            dtYeast.Columns.Add("attenuation", typeof(string));
            dtYeast.Columns.Add("notes", typeof(string));
            dtYeast.Columns.Add("best_for", typeof(string));
            dtYeast.Columns.Add("max_reuse", typeof(string));
            dtYeast.Columns.Add("times_cultured", typeof(string));
            dtYeast.Columns.Add("add_to_secondary", typeof(string));
            dtYeast.Columns.Add("display_amount", typeof(string));
            dtYeast.Columns.Add("disp_min_temp", typeof(string));
            dtYeast.Columns.Add("disp_max_temp", typeof(string));
            dtYeast.Columns.Add("inventory", typeof(string));
            dtYeast.Columns.Add("culture_date", typeof(string));

            cbbYeastRecipes.DataSource = ul.dataTableYeasts(ul.ListYeasts(documentYeast));
            cbbYeastRecipes.PopulateColumns();
            cbbYeastRecipes.DisplayMember = "name";
            cbbYeastRecipes.ValueMember = "name";
            cbbYeastRecipes.Columns["version"].Visible = false;
            cbbYeastRecipes.Columns["type"].Visible = false;
            cbbYeastRecipes.Columns["form"].Visible = false;
            cbbYeastRecipes.Columns["amount"].Visible = false;
            cbbYeastRecipes.Columns["amount_is_weight"].Visible = false;
            cbbYeastRecipes.Columns["laboratory"].Visible = false;
            cbbYeastRecipes.Columns["product_id"].Visible = false;
            cbbYeastRecipes.Columns["min_temperature"].Visible = false;
            cbbYeastRecipes.Columns["max_temperature"].Visible = false;
            cbbYeastRecipes.Columns["flocculation"].Visible = false;
            cbbYeastRecipes.Columns["attenuation"].Visible = false;
            cbbYeastRecipes.Columns["notes"].Visible = false;
            cbbYeastRecipes.Columns["best_for"].Visible = false;
            cbbYeastRecipes.Columns["max_reuse"].Visible = false;
            cbbYeastRecipes.Columns["times_cultured"].Visible = false;
            cbbYeastRecipes.Columns["add_to_secondary"].Visible = false;
            cbbYeastRecipes.Columns["display_amount"].Visible = false;
            cbbYeastRecipes.Columns["disp_min_temp"].Visible = false;
            cbbYeastRecipes.Columns["disp_max_temp"].Visible = false;
            cbbYeastRecipes.Columns["inventory"].Visible = false;
            cbbYeastRecipes.Columns["culture_date"].Visible = false;

            cbbYeastRecipes.EditValueChanged += (object sender, EventArgs e) =>
            {
                string name = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("name").ToString();
                string version = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("version").ToString();
                string type = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                string form = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("form").ToString();
                string amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount").ToString();
                string amount_is_weight = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("amount_is_weight").ToString();
                string laboratory = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("laboratory").ToString();
                string product_id = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("product_id").ToString();
                string min_temperature = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("min_temperature").ToString();
                string max_temperature = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("max_temperature").ToString();
                string flocculation = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("flocculation").ToString();
                string attenuation = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("attenuation").ToString();
                string notes = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("notes").ToString();
                string best_for = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("best_for").ToString();
                string max_reuse = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("max_reuse").ToString();
                string times_cultured = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("times_cultured").ToString();
                string add_to_secondary = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("add_to_secondary").ToString();
                string display_amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("display_amount").ToString();
                string disp_min_temp = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("disp_min_temp").ToString();
                string disp_max_temp = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("disp_max_temp").ToString();
                string inventory = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("inventory").ToString();
                string culture_date = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("culture_date").ToString();

                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[0], name);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[1], version);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[2], type);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[3], form);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[4], amount);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[5], amount_is_weight);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[6], laboratory);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[7], product_id);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[8], min_temperature);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[9], max_temperature);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[10], flocculation);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[11], attenuation);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[12], notes);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[13], best_for);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[14], max_reuse);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[15], times_cultured);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], add_to_secondary);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], display_amount);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], disp_min_temp);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], disp_max_temp);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], inventory);
                tableViewYeastRecipes.SetRowCellValue(tableViewYeastRecipes.FocusedRowHandle, tableViewYeastRecipes.Columns[16], culture_date);

                tableYeastsRecipes.Refresh();
            };

            //Mash
            DataTable dtMash = new DataTable();
            tableMashRecipes.DataSource = dtMash;
            dtMash.Columns.Add("name", typeof(string));
            dtMash.Columns.Add("type", typeof(string));
            dtMash.Columns.Add("infuse_amount", typeof(string));
            dtMash.Columns.Add("infuse_temp", typeof(string));
            dtMash.Columns.Add("step_time", typeof(string));

            cbbMashRecipes.DataSource = ul.dataTableMash_Step(ul.ListMashStep(documentMash));
            cbbMashRecipes.PopulateColumns();
            cbbMashRecipes.DisplayMember = "name";
            cbbMashRecipes.ValueMember = "name";
            cbbMashRecipes.Columns["version"].Visible = false;
            cbbMashRecipes.Columns["type"].Visible = false;
            cbbMashRecipes.Columns["infuse_amount"].Visible = false;
            cbbMashRecipes.Columns["step_time"].Visible = false;
            cbbMashRecipes.Columns["step_temp"].Visible = false;
            cbbMashRecipes.Columns["ramp_time"].Visible = false;
            cbbMashRecipes.Columns["end_temp"].Visible = false;
            cbbMashRecipes.Columns["description"].Visible = false;
            cbbMashRecipes.Columns["water_grain_ratio"].Visible = false;
            cbbMashRecipes.Columns["decoction_amt"].Visible = false;
            cbbMashRecipes.Columns["infuse_temp"].Visible = false;
            cbbMashRecipes.Columns["display_step_temp"].Visible = false;
            cbbMashRecipes.Columns["display_infuse_amt"].Visible = false;

            cbbMashRecipes.EditValueChanged += (object sender, EventArgs e) =>
            {
                string type = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                string amount = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("infuse_amount").ToString();
                string infuse_temp = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("infuse_temp").ToString();
                string time = (sender as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("step_time").ToString();

                tableViewMashRecipes.SetRowCellValue(tableViewMashRecipes.FocusedRowHandle, tableViewMashRecipes.Columns[1], type);
                tableViewMashRecipes.SetRowCellValue(tableViewMashRecipes.FocusedRowHandle, tableViewMashRecipes.Columns[2], amount);
                tableViewMashRecipes.SetRowCellValue(tableViewMashRecipes.FocusedRowHandle, tableViewMashRecipes.Columns[3], infuse_temp);
                tableViewMashRecipes.SetRowCellValue(tableViewMashRecipes.FocusedRowHandle, tableViewMashRecipes.Columns[4], time);
            };
        }


        private void tabcontrolRecipes_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            switch (tabcontrolRecipes.SelectedTabPageIndex)
            {
                case 0:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadRecipes();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 0;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 1:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadStyles();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 1;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 2:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadEquipment();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 2;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 3:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadFermentables();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 3;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 4:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadHops();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 4;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 5:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadMiscs();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 5;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 6:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadYeasts();
                        tabcontrolRecipesRight.SelectedTabPageIndex = 6;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
                case 7:
                    {
                        try
                        {
                            splashScreenManager.ShowWaitForm();
                        }
                        catch (Exception) { }
                        loadMashs();
                        DataTable dtMash = new DataTable();
                        tablecontrolMashStep.DataSource = dtMash;
                        dtMash.Columns.Add("name", typeof(string));
                        dtMash.Columns.Add("type", typeof(string));
                        dtMash.Columns.Add("infuse_amount", typeof(string));
                        dtMash.Columns.Add("infuse_temp", typeof(string));
                        dtMash.Columns.Add("step_time", typeof(string));

                        cbbMashStep.DataSource = ul.dataTableMash_Step(ul.ListMashStep(documentMash));
                        cbbMashStep.PopulateColumns();
                        cbbMashStep.DisplayMember = "name";
                        cbbMashStep.ValueMember = "name";
                        cbbMashStep.Columns["version"].Visible = false;
                        cbbMashStep.Columns["type"].Visible = false;
                        cbbMashStep.Columns["infuse_amount"].Visible = false;
                        cbbMashStep.Columns["step_time"].Visible = false;
                        cbbMashStep.Columns["step_temp"].Visible = false;
                        cbbMashStep.Columns["ramp_time"].Visible = false;
                        cbbMashStep.Columns["end_temp"].Visible = false;
                        cbbMashStep.Columns["description"].Visible = false;
                        cbbMashStep.Columns["water_grain_ratio"].Visible = false;
                        cbbMashStep.Columns["decoction_amt"].Visible = false;
                        cbbMashStep.Columns["infuse_temp"].Visible = false;
                        cbbMashStep.Columns["display_step_temp"].Visible = false;
                        cbbMashStep.Columns["display_infuse_amt"].Visible = false;

                        cbbMashStep.EditValueChanged += (object sender1, EventArgs e1) =>
                        {
                            string type = (sender1 as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("type").ToString();
                            string amount = (sender1 as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("infuse_amount").ToString();
                            string infuse_temp = (sender1 as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("infuse_temp").ToString();
                            string time = (sender1 as DevExpress.XtraEditors.LookUpEdit).GetColumnValue("step_time").ToString();

                            tableviewMashStep.SetRowCellValue(tableviewMashStep.FocusedRowHandle, tableviewMashStep.Columns[1], type);
                            tableviewMashStep.SetRowCellValue(tableviewMashStep.FocusedRowHandle, tableviewMashStep.Columns[2], amount);
                            tableviewMashStep.SetRowCellValue(tableviewMashStep.FocusedRowHandle, tableviewMashStep.Columns[3], infuse_temp);
                            tableviewMashStep.SetRowCellValue(tableviewMashStep.FocusedRowHandle, tableviewMashStep.Columns[4], time);
                        };
                        tabcontrolRecipesRight.SelectedTabPageIndex = 7;
                        try
                        {
                            splashScreenManager.CloseWaitForm();
                        }
                        catch (Exception) { }
                        break;
                    }
            }
        }

        


        //Fermentables
        private void btnSaveFermentables_Click(object sender, EventArgs e)
        {
            if (txtNameFermentables.Text == "")
            {
                message.title = "Error";
                message.Content = "Fermentable name not null";
                message.ShowDialog();
            }
            else
            {

                XmlNode root = documentFermentable.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::FERMENTABLE[NAME='"+txtNameFermentables.Text+"']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = cbbTypeFermentables.Text;
                    node.ChildNodes[3].InnerText = txtAmountFermentables.Text.Replace("mg", "");
                    node.ChildNodes[4].InnerText = txtYieldFermentables.Text;
                    node.ChildNodes[5].InnerText = txtColorFermentables.Text;
                    if (cbAddAfterBoilFermentables.Checked)
                    {
                        node.ChildNodes[6].InnerText = "TRUE";
                    }
                    else
                    {
                        node.ChildNodes[6].InnerText = "FALSE";
                    }
                    node.ChildNodes[7].InnerText = txtOriginFermentables.Text;
                    node.ChildNodes[8].InnerText = txtSupplierFermentables.Text;
                    node.ChildNodes[9].InnerText = txtNotesFermentables.Text;
                    node.ChildNodes[10].InnerText = txtCoarseFineDiffFermentables.Text;
                    node.ChildNodes[11].InnerText = txtMoistureFermentables.Text;
                    node.ChildNodes[12].InnerText = txtDPFermentables.Text;
                    node.ChildNodes[13].InnerText = txtProteinFermentables.Text;
                    node.ChildNodes[14].InnerText = txtMaxInBatchFermentables.Text;
                    if (cbRecommendMashFermentables.Checked)
                    {
                        node.ChildNodes[15].InnerText = "TRUE";
                    }
                    else
                    {
                        node.ChildNodes[15].InnerText = "FALSE";
                    }
                    node.ChildNodes[16].InnerText = txtBitternessFermentables.Text;
                    node.ChildNodes[17].InnerText = "0.00 lb";
                    node.ChildNodes[18].InnerText = "0.00 lb";
                    node.ChildNodes[19].InnerText = "0.000";
                    node.ChildNodes[20].InnerText = "0.0 SRM";
                    documentFermentable.Save(fileFermentables);
                    message.title = "Update Fermentables";
                    message.Content = "Update success";
                    message.ShowDialog();
                }
                else
                {
                    XmlElement fermentable = documentFermentable.CreateElement("FERMENTABLE");

                    XmlElement name = documentFermentable.CreateElement("NAME");
                    name.InnerText = txtNameFermentables.Text;

                    XmlElement version = documentFermentable.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = documentFermentable.CreateElement("TYPE");
                    type.InnerText = cbbTypeFermentables.Text;

                    XmlElement amount = documentFermentable.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountFermentables.Text.Replace("mg","");

                    XmlElement yield = documentFermentable.CreateElement("YIELD");
                    yield.InnerText = txtYieldFermentables.Text;

                    XmlElement color = documentFermentable.CreateElement("COLOR");
                    color.InnerText = txtColorFermentables.Text;

                    XmlElement add_after_boil = documentFermentable.CreateElement("ADD_AFTER_BOIL");
                    if (cbAddAfterBoilFermentables.Checked)
                    {
                        add_after_boil.InnerText = "TRUE";
                    }
                    else
                    {
                        add_after_boil.InnerText = "FALSE";
                    }

                    XmlElement origin = documentFermentable.CreateElement("ORIGIN");
                    origin.InnerText = txtOriginFermentables.Text;

                    XmlElement supplier = documentFermentable.CreateElement("SUPPLIER");
                    supplier.InnerText = txtSupplierFermentables.Text;

                    XmlElement notes = documentFermentable.CreateElement("NOTES");
                    notes.InnerText = txtNotesFermentables.Text;

                    XmlElement coarse_fine_diff = documentFermentable.CreateElement("COARSE_FINE_DIFF");
                    coarse_fine_diff.InnerText = txtCoarseFineDiffFermentables.Text;

                    XmlElement moisture = documentFermentable.CreateElement("MOISTURE");
                    moisture.InnerText = txtMoistureFermentables.Text;

                    XmlElement diastatic_power = documentFermentable.CreateElement("DIASTATIC_POWER");
                    diastatic_power.InnerText = txtDPFermentables.Text;

                    XmlElement protein = documentFermentable.CreateElement("PROTEIN");
                    protein.InnerText = txtProteinFermentables.Text;

                    XmlElement max_in_batch = documentFermentable.CreateElement("MAX_IN_BATCH");
                    max_in_batch.InnerText = txtMaxInBatchFermentables.Text;

                    XmlElement recommend_mash = documentFermentable.CreateElement("RECOMMEND_MASH");
                    if (cbRecommendMashFermentables.Checked)
                    {
                        recommend_mash.InnerText = "TRUE";
                    }
                    else
                    {
                        recommend_mash.InnerText = "FALSE";
                    }

                    XmlElement ibu_gal_per_lb = documentFermentable.CreateElement("IBU_GAL_PER_LB");
                    ibu_gal_per_lb.InnerText = txtBitternessFermentables.Text;

                    XmlElement display_amount = documentFermentable.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 lb";

                    XmlElement inventory = documentFermentable.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 lb";

                    XmlElement potential = documentFermentable.CreateElement("POTENTIAL");
                    potential.InnerText = "0.000";

                    XmlElement display_color = documentFermentable.CreateElement("DISPLAY_COLOR");
                    display_color.InnerText = "";


                    fermentable.AppendChild(name);
                    fermentable.AppendChild(version);
                    fermentable.AppendChild(type);
                    fermentable.AppendChild(amount);
                    fermentable.AppendChild(yield);
                    fermentable.AppendChild(color);
                    fermentable.AppendChild(add_after_boil);
                    fermentable.AppendChild(origin);
                    fermentable.AppendChild(supplier);
                    fermentable.AppendChild(notes);
                    fermentable.AppendChild(coarse_fine_diff);
                    fermentable.AppendChild(moisture);
                    fermentable.AppendChild(diastatic_power);
                    fermentable.AppendChild(protein);
                    fermentable.AppendChild(max_in_batch);
                    fermentable.AppendChild(recommend_mash);
                    fermentable.AppendChild(ibu_gal_per_lb);
                    fermentable.AppendChild(display_amount);
                    fermentable.AppendChild(inventory);
                    fermentable.AppendChild(potential);
                    fermentable.AppendChild(display_color);

                    documentFermentable.DocumentElement.AppendChild(fermentable);

                    XmlTextWriter writer = new XmlTextWriter(fileFermentables, null);
                    writer.Formatting = Formatting.Indented;
                    documentFermentable.Save(writer);

                    message.title = "Save Fermentables";
                    message.Content = "Save success";
                    message.ShowDialog();
                }
                loadFermentables();
                fsFermentables.Close();
            }
        }

        private void btnNewFermentables_Click(object sender, EventArgs e)
        {
            txtNameFermentables.Text = "";
            cbbTypeFermentables.Text = "";
            txtAmountFermentables.Text = "0.000 mg";
            txtYieldFermentables.Text = "0.000";
            txtColorFermentables.Text = "0.0";
            cbAddAfterBoilFermentables.Checked = false;
            txtOriginFermentables.Text = "";
            txtSupplierFermentables.Text = "";
            txtCoarseFineDiffFermentables.Text = "0.000";
            txtMoistureFermentables.Text = "0.000";
            txtDPFermentables.Text = "0.000";
            txtProteinFermentables.Text = "0.000";
            txtMaxInBatchFermentables.Text = "100.000";
            cbRecommendMashFermentables.Checked = false;
            cbIsMashFermentables.Checked = false;
            txtBitternessFermentables.Text = "0.000";
            txtNotesFermentables.Text = "";
            btnSaveFermentables.Enabled = true;
        }

        private void btnDeleteFermentable_Click(object sender, EventArgs e)
        {
            if (txtNameFermentables.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select fermentable";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentFermentable.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::FERMENTABLE[NAME='"+txtNameFermentables.Text+"']");
                if (node != null)
                {
                    documentFermentable.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsFermentables = new FileStream(fileFermentables, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentFermentable.Save(fsFermentables);
                message.title = "Delete Fermentables";
                message.Content = "Delete success";
                message.ShowDialog();
                loadFermentables();
                fsFermentables.Close();
            }
        }

        private void btnExportFermentables_Click(object sender, EventArgs e)
        {
            if (txtNameFermentables.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select fermentable";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement fermentables = doc.CreateElement("FERMENTABLES");

                    XmlElement fermentable = doc.CreateElement("FERMENTABLE");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameFermentables.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = cbbTypeFermentables.Text;

                    XmlElement amount = doc.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountFermentables.Text.Replace("mg", "");

                    XmlElement yield = doc.CreateElement("YIELD");
                    yield.InnerText = txtYieldFermentables.Text;

                    XmlElement color = doc.CreateElement("COLOR");
                    color.InnerText = txtColorFermentables.Text;

                    XmlElement add_after_boil = doc.CreateElement("ADD_AFTER_BOIL");
                    if (cbAddAfterBoilFermentables.Checked)
                    {
                        add_after_boil.InnerText = "TRUE";
                    }
                    else
                    {
                        add_after_boil.InnerText = "FALSE";
                    }

                    XmlElement origin = doc.CreateElement("ORIGIN");
                    origin.InnerText = txtOriginFermentables.Text;

                    XmlElement supplier = doc.CreateElement("SUPPLIER");
                    supplier.InnerText = txtSupplierFermentables.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesFermentables.Text;

                    XmlElement coarse_fine_diff = doc.CreateElement("COARSE_FINE_DIFF");
                    coarse_fine_diff.InnerText = txtCoarseFineDiffFermentables.Text;

                    XmlElement moisture = doc.CreateElement("MOISTURE");
                    moisture.InnerText = txtMoistureFermentables.Text;

                    XmlElement diastatic_power = doc.CreateElement("DIASTATIC_POWER");
                    diastatic_power.InnerText = txtDPFermentables.Text;

                    XmlElement protein = doc.CreateElement("PROTEIN");
                    protein.InnerText = txtProteinFermentables.Text;

                    XmlElement max_in_batch = doc.CreateElement("MAX_IN_BATCH");
                    max_in_batch.InnerText = txtMaxInBatchFermentables.Text;

                    XmlElement recommend_mash = doc.CreateElement("RECOMMEND_MASH");
                    if (cbRecommendMashFermentables.Checked)
                    {
                        recommend_mash.InnerText = "TRUE";
                    }
                    else
                    {
                        recommend_mash.InnerText = "FALSE";
                    }

                    XmlElement ibu_gal_per_lb = doc.CreateElement("IBU_GAL_PER_LB");
                    ibu_gal_per_lb.InnerText = txtBitternessFermentables.Text;

                    XmlElement display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 lb";

                    XmlElement inventory = doc.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 lb";

                    XmlElement potential = doc.CreateElement("POTENTIAL");
                    potential.InnerText = "0.000";

                    XmlElement display_color = doc.CreateElement("DISPLAY_COLOR");
                    display_color.InnerText = "";


                    fermentable.AppendChild(name);
                    fermentable.AppendChild(version);
                    fermentable.AppendChild(type);
                    fermentable.AppendChild(amount);
                    fermentable.AppendChild(yield);
                    fermentable.AppendChild(color);
                    fermentable.AppendChild(add_after_boil);
                    fermentable.AppendChild(origin);
                    fermentable.AppendChild(supplier);
                    fermentable.AppendChild(notes);
                    fermentable.AppendChild(coarse_fine_diff);
                    fermentable.AppendChild(moisture);
                    fermentable.AppendChild(diastatic_power);
                    fermentable.AppendChild(protein);
                    fermentable.AppendChild(max_in_batch);
                    fermentable.AppendChild(recommend_mash);
                    fermentable.AppendChild(ibu_gal_per_lb);
                    fermentable.AppendChild(display_amount);
                    fermentable.AppendChild(inventory);
                    fermentable.AppendChild(potential);
                    fermentable.AppendChild(display_color);

                    fermentables.AppendChild(fermentable);
                    doc.AppendChild(fermentables);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  fermentable";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }

        }

        private void btnImportFermentables_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Fermentables> fermentables = new List<Fermentables>();
                fermentables = ul.ListFermentables(doc);
                for (int i = 0; i < fermentables.Count; i++)
                {
                    XmlElement fermentable = documentFermentable.CreateElement("FERMENTABLE");

                    XmlElement name = documentFermentable.CreateElement("NAME");
                    name.InnerText = fermentables[i].getNAME().ToString();

                    XmlElement version = documentFermentable.CreateElement("VERSION");
                    version.InnerText = fermentables[i].getVERSION().ToString();

                    XmlElement type = documentFermentable.CreateElement("TYPE");
                    type.InnerText = fermentables[i].getTYPE().ToString();

                    XmlElement amount = documentFermentable.CreateElement("AMOUNT");
                    amount.InnerText = fermentables[i].getAMOUNT().ToString();

                    XmlElement yield = documentFermentable.CreateElement("YIELD");
                    yield.InnerText = fermentables[i].getYIELD().ToString();

                    XmlElement color = documentFermentable.CreateElement("COLOR");
                    color.InnerText = fermentables[i].getCOLOR().ToString();

                    XmlElement add_after_boil = documentFermentable.CreateElement("ADD_AFTER_BOIL");
                    add_after_boil.InnerText = fermentables[i].getADD_AFTER_BOIL().ToString();

                    XmlElement origin = documentFermentable.CreateElement("ORIGIN");
                    origin.InnerText = fermentables[i].getORIGIN().ToString();

                    XmlElement supplier = documentFermentable.CreateElement("SUPPLIER");
                    supplier.InnerText = fermentables[i].getSUPPLIER().ToString();

                    XmlElement notes = documentFermentable.CreateElement("NOTES");
                    notes.InnerText = fermentables[i].getNOTES().ToString();

                    XmlElement coarse_fine_diff = documentFermentable.CreateElement("COARSE_FINE_DIFF");
                    coarse_fine_diff.InnerText = fermentables[i].getCOARSE_FINE_DIFF().ToString();

                    XmlElement moisture = documentFermentable.CreateElement("MOISTURE");
                    moisture.InnerText = fermentables[i].getMOISTURE().ToString();

                    XmlElement diastatic_power = documentFermentable.CreateElement("DIASTATIC_POWER");
                    diastatic_power.InnerText = fermentables[i].getDIASTATIC_POWER().ToString();

                    XmlElement protein = documentFermentable.CreateElement("PROTEIN");
                    protein.InnerText = fermentables[i].getPROTEIN().ToString();

                    XmlElement max_in_batch = documentFermentable.CreateElement("MAX_IN_BATCH");
                    max_in_batch.InnerText = fermentables[i].getMAX_IN_BATCH().ToString();

                    XmlElement recommend_mash = documentFermentable.CreateElement("RECOMMEND_MASH");
                    recommend_mash.InnerText = fermentables[i].getRECOMMEND_MASH().ToString();

                    XmlElement ibu_gal_per_lb = documentFermentable.CreateElement("IBU_GAL_PER_LB");
                    ibu_gal_per_lb.InnerText = fermentables[i].getIBU_GAL_PER_LB().ToString();

                    XmlElement display_amount = documentFermentable.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = fermentables[i].getDISPLAY_AMOUNT().ToString();

                    XmlElement inventory = documentFermentable.CreateElement("INVENTORY");
                    inventory.InnerText = fermentables[i].getINVENTORY().ToString();

                    XmlElement potential = documentFermentable.CreateElement("POTENTIAL");
                    potential.InnerText = fermentables[i].getPOTENTIAL().ToString();

                    XmlElement display_color = documentFermentable.CreateElement("DISPLAY_COLOR");
                    display_color.InnerText = fermentables[i].getDISPLAY_COLOR().ToString();


                    fermentable.AppendChild(name);
                    fermentable.AppendChild(version);
                    fermentable.AppendChild(type);
                    fermentable.AppendChild(amount);
                    fermentable.AppendChild(yield);
                    fermentable.AppendChild(color);
                    fermentable.AppendChild(add_after_boil);
                    fermentable.AppendChild(origin);
                    fermentable.AppendChild(supplier);
                    fermentable.AppendChild(notes);
                    fermentable.AppendChild(coarse_fine_diff);
                    fermentable.AppendChild(moisture);
                    fermentable.AppendChild(diastatic_power);
                    fermentable.AppendChild(protein);
                    fermentable.AppendChild(max_in_batch);
                    fermentable.AppendChild(recommend_mash);
                    fermentable.AppendChild(ibu_gal_per_lb);
                    fermentable.AppendChild(display_amount);
                    fermentable.AppendChild(inventory);
                    fermentable.AppendChild(potential);
                    fermentable.AppendChild(display_color);

                    documentFermentable.DocumentElement.InsertAfter(fermentable, documentFermentable.DocumentElement.LastChild);
                    try
                    {
                        fsFermentables = new FileStream(fileFermentables, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }

                    documentFermentable.Save(fsFermentables);
                    message.title = "Import  fermentable";
                    message.Content = "Import success";
                    message.ShowDialog();
                }
                loadFermentables();
                fsPath.Close();
            }

        }

        private void tableFermentables_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameFermentables.Text = tableViewFermentable.GetFocusedDataRow()["name"].ToString();
                cbbTypeFermentables.Text = tableViewFermentable.GetFocusedDataRow()["type"].ToString();
                txtAmountFermentables.Text = tableViewFermentable.GetFocusedDataRow()["amount"].ToString() + " mg";
                txtYieldFermentables.Text = tableViewFermentable.GetFocusedDataRow()["yield"].ToString();
                txtColorFermentables.Text = tableViewFermentable.GetFocusedDataRow()["color"].ToString();
                var add_after_boil = tableViewFermentable.GetFocusedDataRow()["add_after_boil"].ToString();
                if (add_after_boil == "TRUE")
                {
                    cbAddAfterBoilFermentables.Checked = true;
                }
                else
                {
                    cbAddAfterBoilFermentables.Checked = false;
                }
                txtOriginFermentables.Text = tableViewFermentable.GetFocusedDataRow()["origin"].ToString();
                txtSupplierFermentables.Text = tableViewFermentable.GetFocusedDataRow()["supplier"].ToString();
                txtCoarseFineDiffFermentables.Text = tableViewFermentable.GetFocusedDataRow()["coarse_fine_diff"].ToString();
                txtMoistureFermentables.Text = tableViewFermentable.GetFocusedDataRow()["moisture"].ToString();
                txtDPFermentables.Text = tableViewFermentable.GetFocusedDataRow()["diastatic_power"].ToString();
                txtProteinFermentables.Text = tableViewFermentable.GetFocusedDataRow()["protein"].ToString();
                txtMaxInBatchFermentables.Text = tableViewFermentable.GetFocusedDataRow()["max_in_batch"].ToString();
                var recommend_mash = tableViewFermentable.GetFocusedDataRow()["recommend_mash"].ToString();
                if (recommend_mash == "TRUE")
                {
                    cbRecommendMashFermentables.Checked = true;
                }
                else
                {
                    cbRecommendMashFermentables.Checked = false;
                }

                txtBitternessFermentables.Text = tableViewFermentable.GetFocusedDataRow()["ibu_gal_per_lb"].ToString();
                txtNotesFermentables.Text = tableViewFermentable.GetFocusedDataRow()["notes"].ToString();

            }
            catch (Exception) { }
        }
        
        //Yeast
        private void btnNewYeast_Click(object sender, EventArgs e)
        {
            txtNameYeast.Text = "";
            cbbTypeYeast.Text = "";
            cbbFormYeast.Text = "";
            txtAmountYeast.Text = "0.000 mL";
            cbAmountIsWeightYeast.Checked = false;
            txtLabYeast.Text = "";
            txtProductIDYeast.Text = "";
            txtMinTempYeast.Text = "0.000 C";
            txtMaxTempYeast.Text = "32.000 C";
            cbbFlocculationYeast.Text = "";
            txtAttenutionYeast.Text = "75.000";
            txtTimeReculturedYeast.Text = "0";
            txtMaxReculturesYeast.Text = "10";
            cbAddToSecondaryYeasts.Checked = false;
            txtBestForYeast.Text = "";
            txtNotesYeast.Text = "";

        }

        private void btnSaveYeast_Click(object sender, EventArgs e)
        {
            if (txtNameYeast.Text == "")
            {
                message.title = "Error";
                message.Content = "Yeast name not null";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentYeast.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::YEAST[NAME='" + txtNameYeast.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = cbbTypeYeast.Text;
                    node.ChildNodes[3].InnerText = cbbFormYeast.Text;
                    node.ChildNodes[4].InnerText = txtAmountYeast.Text.Replace("mL","");
                    if (cbAmountIsWeightYeast.Checked)
                    {
                        node.ChildNodes[5].InnerText = "TRUE";
                    }
                    else
                    {
                        node.ChildNodes[5].InnerText = "FALSE";
                    }
                    node.ChildNodes[6].InnerText = txtLabYeast.Text;
                    node.ChildNodes[7].InnerText = txtProductIDYeast.Text;
                    node.ChildNodes[8].InnerText = txtMinTempYeast.Text.Replace("C","");
                    node.ChildNodes[9].InnerText = txtMaxTempYeast.Text.Replace("C", "");
                    node.ChildNodes[10].InnerText = cbbFlocculationYeast.Text;
                    node.ChildNodes[11].InnerText = txtAttenutionYeast.Text;
                    node.ChildNodes[12].InnerText = txtNotesYeast.Text;
                    node.ChildNodes[13].InnerText = txtBestForYeast.Text;
                    node.ChildNodes[14].InnerText = txtMaxReculturesYeast.Text;
                    node.ChildNodes[15].InnerText = txtTimeReculturedYeast.Text;
                    if (cbAddToSecondaryYeasts.Checked)
                    {
                        node.ChildNodes[16].InnerText = "TRUE";
                    }
                    else
                    {
                        node.ChildNodes[16].InnerText = "FALSE";
                    }

                    node.ChildNodes[17].InnerText = "35 ml";
                    node.ChildNodes[18].InnerText = "64.9 F";
                    node.ChildNodes[19].InnerText = "68.0 F";
                    node.ChildNodes[20].InnerText = "0 Pkgs";
                    node.ChildNodes[21].InnerText = "8/31/2014";
                    documentYeast.Save(fileYeast);
                    message.title = "Update Yeasts";
                    message.Content = "Update success";
                    message.ShowDialog();
                }
                else
                {
                    XmlElement yeast = documentYeast.CreateElement("YEAST");

                    XmlElement name = documentYeast.CreateElement("NAME");
                    name.InnerText = txtNameYeast.Text;

                    XmlElement version = documentYeast.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = documentYeast.CreateElement("TYPE");
                    type.InnerText = cbbTypeYeast.Text;

                    XmlElement form = documentYeast.CreateElement("FORM");
                    form.InnerText = cbbFormYeast.Text;

                    XmlElement amount = documentYeast.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountYeast.Text.Replace("mL","");

                    XmlElement amount_is_weight = documentYeast.CreateElement("AMOUNT_IS_WEIGHT");
                    if (cbAmountIsWeightYeast.Checked)
                    {
                        amount_is_weight.InnerText = "TRUE";
                    }
                    else
                    {
                        amount_is_weight.InnerText = "FALSE";

                    }
                    XmlElement laboratory = documentYeast.CreateElement("LABORATORY");
                    laboratory.InnerText = txtLabYeast.Text;

                    XmlElement product_id = documentYeast.CreateElement("PRODUCT_ID");
                    product_id.InnerText = txtProductIDYeast.Text;

                    XmlElement min_temperature = documentYeast.CreateElement("MIN_TEMPERATURE");
                    min_temperature.InnerText = txtMinTempYeast.Text.Replace("C","");

                    XmlElement max_temperature = documentYeast.CreateElement("MAX_TEMPERATURE");
                    max_temperature.InnerText = txtMaxTempYeast.Text.Replace("C", "");

                    XmlElement flocculation = documentYeast.CreateElement("FLOCCULATION");
                    flocculation.InnerText = cbbFlocculationYeast.Text;

                    XmlElement attenuation = documentYeast.CreateElement("ATTENUATION");
                    attenuation.InnerText = txtAttenutionYeast.Text;

                    XmlElement notes = documentYeast.CreateElement("NOTES");
                    notes.InnerText = txtNotesYeast.Text;

                    XmlElement best_for = documentYeast.CreateElement("BEST_FOR");
                    best_for.InnerText = txtBestForYeast.Text;

                    XmlElement max_reuse = documentYeast.CreateElement("MAX_REUSE");
                    max_reuse.InnerText = txtMaxReculturesYeast.Text;

                    XmlElement times_cultured = documentYeast.CreateElement("TIMES_CULTURED");
                    times_cultured.InnerText = txtTimeReculturedYeast.Text;

                    XmlElement add_to_secondary = documentYeast.CreateElement("ADD_TO_SECONDARY");
                    if (cbAddToSecondaryYeasts.Checked)
                    {
                        add_to_secondary.InnerText = "TRUE";
                    }
                    else
                    {
                        add_to_secondary.InnerText = "FALSE";
                    }

                    XmlElement display_amount = documentYeast.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 lb";

                    XmlElement disp_min_temp = documentYeast.CreateElement("DISP_MIN_TEMP");
                    disp_min_temp.InnerText = "0.00 lb";

                    XmlElement disp_max_temp = documentYeast.CreateElement("DISP_MAX_TEMP");
                    disp_max_temp.InnerText = "0.000";

                    XmlElement inventory = documentYeast.CreateElement("INVENTORY");
                    inventory.InnerText = "";

                    XmlElement culture_date = documentYeast.CreateElement("CULTURE_DATE");
                    culture_date.InnerText = "";


                    yeast.AppendChild(name);
                    yeast.AppendChild(version);
                    yeast.AppendChild(type);
                    yeast.AppendChild(form);
                    yeast.AppendChild(amount);
                    yeast.AppendChild(amount_is_weight);
                    yeast.AppendChild(laboratory);
                    yeast.AppendChild(product_id);
                    yeast.AppendChild(min_temperature);
                    yeast.AppendChild(max_temperature);
                    yeast.AppendChild(flocculation);
                    yeast.AppendChild(attenuation);
                    yeast.AppendChild(notes);
                    yeast.AppendChild(best_for);
                    yeast.AppendChild(max_reuse);
                    yeast.AppendChild(times_cultured);
                    yeast.AppendChild(add_to_secondary);
                    yeast.AppendChild(display_amount);
                    yeast.AppendChild(disp_min_temp);
                    yeast.AppendChild(disp_max_temp);
                    yeast.AppendChild(inventory);
                    yeast.AppendChild(culture_date);

                    documentYeast.DocumentElement.AppendChild(yeast);
                    try
                    {
                        fsYeast = new FileStream(fileYeast, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    XmlTextWriter writer = new XmlTextWriter(fsYeast, null);
                    writer.Formatting = Formatting.Indented;
                    documentYeast.Save(writer);

                    message.title = "Save Yeasts";
                    message.Content = "Save success";
                    message.ShowDialog();
                }
                loadYeasts();
                fsYeast.Close();
            }
        }

        private void btnDeleteYeasts_Click(object sender, EventArgs e)
        {
            if (txtNameYeast.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select yeast";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentYeast.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::YEAST[NAME='" + txtNameYeast.Text + "']");
                if (node != null)
                {
                    documentYeast.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsYeast = new FileStream(fileYeast, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentYeast.Save(fsYeast);
                message.title = "Delete Yeast";
                message.Content = "Delete success";
                message.ShowDialog();
                loadYeasts();
                fsYeast.Close();
            }
        }

        private void btnExportYeast_Click(object sender, EventArgs e)
        {
            if (txtNameYeast.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select yeast";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement yeasts = doc.CreateElement("YEASTS");

                    XmlElement yeast = doc.CreateElement("YEAST");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameYeast.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = cbbTypeYeast.Text;

                    XmlElement form = doc.CreateElement("FORM");
                    form.InnerText = cbbFormYeast.Text;

                    XmlElement amount = doc.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountYeast.Text;

                    XmlElement amount_is_weight = doc.CreateElement("AMOUNT_IS_WEIGHT");
                    if (cbAmountIsWeightYeast.Checked)
                    {
                        amount_is_weight.InnerText = "TRUE";
                    }
                    else
                    {
                        amount_is_weight.InnerText = "FALSE";

                    }
                    XmlElement laboratory = doc.CreateElement("LABORATORY");
                    laboratory.InnerText = txtLabYeast.Text;

                    XmlElement product_id = doc.CreateElement("PRODUCT_ID");
                    product_id.InnerText = txtProductIDYeast.Text;

                    XmlElement min_temperature = doc.CreateElement("MIN_TEMPERATURE");
                    min_temperature.InnerText = txtMinTempYeast.Text;

                    XmlElement max_temperature = doc.CreateElement("MAX_TEMPERATURE");
                    max_temperature.InnerText = txtMaxTempYeast.Text;

                    XmlElement flocculation = doc.CreateElement("FLOCCULATION");
                    flocculation.InnerText = cbbFlocculationYeast.Text;

                    XmlElement attenuation = doc.CreateElement("ATTENUATION");
                    attenuation.InnerText = txtAttenutionYeast.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesYeast.Text;

                    XmlElement best_for = doc.CreateElement("BEST_FOR");
                    best_for.InnerText = txtBestForYeast.Text;

                    XmlElement max_reuse = doc.CreateElement("MAX_REUSE");
                    max_reuse.InnerText = txtMaxReculturesYeast.Text;

                    XmlElement times_cultured = doc.CreateElement("TIMES_CULTURED");
                    times_cultured.InnerText = txtTimeReculturedYeast.Text;

                    XmlElement add_to_secondary = doc.CreateElement("ADD_TO_SECONDARY");
                    if (cbAddToSecondaryYeasts.Checked)
                    {
                        add_to_secondary.InnerText = "TRUE";
                    }
                    else
                    {
                        add_to_secondary.InnerText = "FALSE";
                    }

                    XmlElement display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 lb";

                    XmlElement disp_min_temp = doc.CreateElement("DISP_MIN_TEMP");
                    disp_min_temp.InnerText = "0.00 lb";

                    XmlElement disp_max_temp = doc.CreateElement("DISP_MAX_TEMP");
                    disp_max_temp.InnerText = "0.000";

                    XmlElement inventory = doc.CreateElement("INVENTORY");
                    inventory.InnerText = "";

                    XmlElement culture_date = doc.CreateElement("CULTURE_DATE");
                    culture_date.InnerText = "";


                    yeast.AppendChild(name);
                    yeast.AppendChild(version);
                    yeast.AppendChild(type);
                    yeast.AppendChild(form);
                    yeast.AppendChild(amount);
                    yeast.AppendChild(amount_is_weight);
                    yeast.AppendChild(laboratory);
                    yeast.AppendChild(product_id);
                    yeast.AppendChild(min_temperature);
                    yeast.AppendChild(max_temperature);
                    yeast.AppendChild(flocculation);
                    yeast.AppendChild(attenuation);
                    yeast.AppendChild(notes);
                    yeast.AppendChild(best_for);
                    yeast.AppendChild(max_reuse);
                    yeast.AppendChild(times_cultured);
                    yeast.AppendChild(add_to_secondary);
                    yeast.AppendChild(display_amount);
                    yeast.AppendChild(disp_min_temp);
                    yeast.AppendChild(disp_max_temp);
                    yeast.AppendChild(inventory);
                    yeast.AppendChild(culture_date);

                    yeasts.AppendChild(yeast);
                    doc.AppendChild(yeasts);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  yeast";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportYeast_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Yeast> yeasts = new List<Yeast>();
                yeasts = ul.ListYeasts(doc);
                for (int i = 0; i < yeasts.Count; i++)
                {
                   
                    XmlElement yeast = documentYeast.CreateElement("YEAST");

                    XmlElement name = documentYeast.CreateElement("NAME");
                    name.InnerText = yeasts[i].getNAME().ToString();

                    XmlElement version = documentYeast.CreateElement("VERSION");
                    version.InnerText = yeasts[i].getVERSION().ToString();

                    XmlElement type = documentYeast.CreateElement("TYPE");
                    type.InnerText = yeasts[i].getTYPE().ToString();

                    XmlElement form = documentYeast.CreateElement("FORM");
                    form.InnerText = yeasts[i].getFORM().ToString();

                    XmlElement amount = documentYeast.CreateElement("AMOUNT");
                    amount.InnerText = yeasts[i].getAMOUNT().ToString();

                    XmlElement amount_is_weight = documentYeast.CreateElement("AMOUNT_IS_WEIGHT");
                    amount_is_weight.InnerText = yeasts[i].getAMOUNT_IS_WEIGHT().ToString();

                    XmlElement laboratory = documentYeast.CreateElement("LABORATORY");
                    laboratory.InnerText = yeasts[i].getLABORATORY().ToString();

                    XmlElement product_id = documentYeast.CreateElement("PRODUCT_ID");
                    product_id.InnerText = yeasts[i].getPRODUCT_ID().ToString();

                    XmlElement min_temperature = documentYeast.CreateElement("MIN_TEMPERATURE");
                    min_temperature.InnerText = yeasts[i].getMIN_TEMPERATURE().ToString();

                    XmlElement max_temperature = documentYeast.CreateElement("MAX_TEMPERATURE");
                    max_temperature.InnerText = yeasts[i].getMAX_TEMPERATURE().ToString();

                    XmlElement flocculation = documentYeast.CreateElement("FLOCCULATION");
                    flocculation.InnerText = yeasts[i].getFLOCCULATION().ToString();

                    XmlElement attenuation = documentYeast.CreateElement("ATTENUATION");
                    attenuation.InnerText = yeasts[i].getATTENUATION().ToString();

                    XmlElement notes = documentYeast.CreateElement("NOTES");
                    notes.InnerText = yeasts[i].getNOTES().ToString();

                    XmlElement best_for = documentYeast.CreateElement("BEST_FOR");
                    best_for.InnerText = yeasts[i].getBEST_FOR().ToString();

                    XmlElement max_reuse = documentYeast.CreateElement("MAX_REUSE");
                    max_reuse.InnerText = yeasts[i].getMAX_REUSE().ToString();

                    XmlElement times_cultured = documentYeast.CreateElement("TIMES_CULTURED");
                    times_cultured.InnerText = yeasts[i].getTIMES_CULTURED().ToString();

                    XmlElement add_to_secondary = documentYeast.CreateElement("ADD_TO_SECONDARY");
                    add_to_secondary.InnerText = yeasts[i].getADD_TO_SECONDARY().ToString();

                    XmlElement display_amount = documentYeast.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = yeasts[i].getDISPLAY_AMOUNT().ToString();

                    XmlElement disp_min_temp = documentYeast.CreateElement("DISP_MIN_TEMP");
                    disp_min_temp.InnerText = yeasts[i].getDISP_MIN_TEMP().ToString();

                    XmlElement disp_max_temp = documentYeast.CreateElement("DISP_MAX_TEMP");
                    disp_max_temp.InnerText = yeasts[i].getDISP_MAX_TEMP().ToString();

                    XmlElement inventory = documentYeast.CreateElement("INVENTORY");
                    inventory.InnerText = yeasts[i].getINVENTORY().ToString();

                    XmlElement culture_date = documentYeast.CreateElement("CULTURE_DATE");
                    culture_date.InnerText = yeasts[i].getCULTURE_DATE().ToString();


                    yeast.AppendChild(name);
                    yeast.AppendChild(version);
                    yeast.AppendChild(type);
                    yeast.AppendChild(form);
                    yeast.AppendChild(amount);
                    yeast.AppendChild(amount_is_weight);
                    yeast.AppendChild(laboratory);
                    yeast.AppendChild(product_id);
                    yeast.AppendChild(min_temperature);
                    yeast.AppendChild(max_temperature);
                    yeast.AppendChild(flocculation);
                    yeast.AppendChild(attenuation);
                    yeast.AppendChild(notes);
                    yeast.AppendChild(best_for);
                    yeast.AppendChild(max_reuse);
                    yeast.AppendChild(times_cultured);
                    yeast.AppendChild(add_to_secondary);
                    yeast.AppendChild(display_amount);
                    yeast.AppendChild(disp_min_temp);
                    yeast.AppendChild(disp_max_temp);
                    yeast.AppendChild(inventory);
                    yeast.AppendChild(culture_date);

                    documentYeast.DocumentElement.InsertAfter(yeast, documentYeast.DocumentElement.LastChild);
                    try
                    {
                        fsYeast = new FileStream(fileYeast, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentYeast.Save(fsYeast);
                    message.title = "Import yeast";
                    message.Content = "Import success";
                    message.ShowDialog();
                }
                loadYeasts();
                fsPath.Close();
            }
        }

        private void tableYeasts_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameYeast.Text = tableViewYeasts.GetFocusedDataRow()["name"].ToString();
                cbbTypeYeast.Text = tableViewYeasts.GetFocusedDataRow()["type"].ToString();
                cbbFormYeast.Text = tableViewYeasts.GetFocusedDataRow()["form"].ToString();
                txtAmountYeast.Text = tableViewYeasts.GetFocusedDataRow()["amount"].ToString() + " mL";
                var amount_is_weight = tableViewYeasts.GetFocusedDataRow()["amount_is_weight"].ToString();
                if (amount_is_weight == "TRUE")
                {
                    cbAmountIsWeightYeast.Checked = true;
                }
                else
                {
                    cbAmountIsWeightYeast.Checked = false;
                }
                txtLabYeast.Text = tableViewYeasts.GetFocusedDataRow()["laboratory"].ToString();
                txtProductIDYeast.Text = tableViewYeasts.GetFocusedDataRow()["product_id"].ToString();
                txtMinTempYeast.Text = tableViewYeasts.GetFocusedDataRow()["min_temperature"].ToString() + " C";
                txtMaxTempYeast.Text = tableViewYeasts.GetFocusedDataRow()["max_temperature"].ToString() + " C";
                cbbFlocculationYeast.Text = tableViewYeasts.GetFocusedDataRow()["flocculation"].ToString();
                txtAttenutionYeast.Text = tableViewYeasts.GetFocusedDataRow()["attenuation"].ToString();
                txtTimeReculturedYeast.Text = tableViewYeasts.GetFocusedDataRow()["times_cultured"].ToString();
                txtMaxReculturesYeast.Text = tableViewYeasts.GetFocusedDataRow()["max_reuse"].ToString();
                var add_to_secondary = tableViewYeasts.GetFocusedDataRow()["add_to_secondary"].ToString();
                if (add_to_secondary == "TRUE")
                {
                    cbAddToSecondaryYeasts.Checked = true;
                }
                else
                {
                    cbAddToSecondaryYeasts.Checked = false;
                }
                txtBestForYeast.Text = tableViewYeasts.GetFocusedDataRow()["best_for"].ToString();
                txtNotesYeast.Text = tableViewYeasts.GetFocusedDataRow()["notes"].ToString();
            }
            catch (Exception) { }
        }

        //Misc
        private void btnNewMiscs_Click(object sender, EventArgs e)
        {
            txtNameMiscs.Text = "";
            cbbTypeMiscs.Text = "";
            cbbUseMiscs.Text = "";
            txtTimeMiscs.Text = "0.000 s";
            txtAmountMiscs.Text = "0.000 mg";
            cbAmountIsWeightMiscs.Checked = true;
            txtUseForMiscs.Text = "";
            txtNotesMiscs.Text = "";
        }

        private void btnSaveMiscs_Click(object sender, EventArgs e)
        {
            if (txtNameMiscs.Text == "")
            {
                message.title = "Error";
                message.Content = "Misc name not null";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentMics.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::MISC[NAME='" + txtNameMiscs.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = cbbTypeMiscs.Text;
                    node.ChildNodes[3].InnerText = cbbUseMiscs.Text;
                    node.ChildNodes[4].InnerText = txtAmountMiscs.Text;
                    node.ChildNodes[5].InnerText = txtTimeMiscs.Text;
                    node.ChildNodes[6].InnerText = txtLabYeast.Text;
                    if (cbAmountIsWeightMiscs.Checked)
                    {
                        node.ChildNodes[7].InnerText = "TRUE";
                    }
                    else
                    {
                        node.ChildNodes[7].InnerText = "FALSE";
                    }
                    node.ChildNodes[8].InnerText = txtUseForMiscs.Text;
                    node.ChildNodes[9].InnerText = txtNotesMiscs.Text;
                    node.ChildNodes[10].InnerText = "6.50 oz";
                    node.ChildNodes[11].InnerText = "0.00 oz";
                    node.ChildNodes[12].InnerText = "5.0 min";
                    try
                    {
                        fsMisc = new FileStream(fileMisc, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    documentMics.Save(fsMisc);
                    message.title = "Update Misc";
                    message.Content = "Update success";
                    message.ShowDialog();
                    fsMisc.Close();
                }
                else
                {
                    XmlElement misc = documentMics.CreateElement("MISC");

                    XmlElement name = documentMics.CreateElement("NAME");
                    name.InnerText = txtNameMiscs.Text;

                    XmlElement version = documentMics.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = documentMics.CreateElement("TYPE");
                    type.InnerText = cbbTypeMiscs.Text;

                    XmlElement use = documentMics.CreateElement("USE");
                    use.InnerText = cbbUseMiscs.Text;

                    XmlElement amount = documentMics.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountMiscs.Text;

                    XmlElement time = documentMics.CreateElement("TIME");
                    time.InnerText = txtTimeMiscs.Text;

                    XmlElement amount_is_weight = documentMics.CreateElement("AMOUNT_IS_WEIGHT");
                    if (cbAmountIsWeightMiscs.Checked)
                    {
                        amount_is_weight.InnerText = "TRUE";
                    }
                    else
                    {
                        amount_is_weight.InnerText = "FALSE";
                    }

                    XmlElement use_for = documentMics.CreateElement("USE_FOR");
                    use_for.InnerText = txtUseForMiscs.Text;

                    XmlElement notes = documentMics.CreateElement("NOTES");
                    notes.InnerText = txtNotesMiscs.Text;

                    XmlElement display_amount = documentMics.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "6.50 oz";

                    XmlElement inventory = documentMics.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 oz";

                    XmlElement display_time = documentMics.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = "5.0 min";

                    misc.AppendChild(name);
                    misc.AppendChild(version);
                    misc.AppendChild(type);
                    misc.AppendChild(use);
                    misc.AppendChild(amount);
                    misc.AppendChild(time);
                    misc.AppendChild(amount_is_weight);
                    misc.AppendChild(notes);
                    misc.AppendChild(display_amount);
                    misc.AppendChild(inventory);
                    misc.AppendChild(display_time);

                    documentMics.DocumentElement.AppendChild(misc);
                    try
                    {
                        fsMisc = new FileStream(fileMisc, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    XmlTextWriter writer = new XmlTextWriter(fsMisc, null);
                    writer.Formatting = Formatting.Indented;
                    documentMics.Save(writer);

                    message.title = "Save Misc";
                    message.Content = "Save success";
                    message.ShowDialog();
                    fsMisc.Close();
                }
                loadMiscs();
            }
        }

        private void btnDeleteMiscs_Click(object sender, EventArgs e)
        {
            if (txtNameMiscs.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select Misc";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentMics.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::MISC[NAME='" + txtNameMiscs.Text + "']");
                if (node != null)
                {
                    documentMics.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsMisc = new FileStream(fileMisc, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentMics.Save(fsMisc);
                message.title = "Delete Misc";
                message.Content = "Delete success";
                message.ShowDialog();
                loadMiscs();
                fsMisc.Close();
            }
        }

        private void btnExportMiscs_Click(object sender, EventArgs e)
        {
            if (txtNameMiscs.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select mics";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement miscs = doc.CreateElement("MISCS");

                    XmlElement misc = doc.CreateElement("MISC");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameMiscs.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = cbbTypeMiscs.Text;

                    XmlElement use = doc.CreateElement("USE");
                    use.InnerText = cbbUseMiscs.Text;

                    XmlElement amount = doc.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountMiscs.Text.Replace("mg","");

                    XmlElement time = doc.CreateElement("TIME");
                    time.InnerText = txtTimeMiscs.Text.Replace("s","");

                    XmlElement amount_is_weight = doc.CreateElement("AMOUNT_IS_WEIGHT");
                    if (cbAmountIsWeightMiscs.Checked)
                    {
                        amount_is_weight.InnerText = "TRUE";
                    }
                    else
                    {
                        amount_is_weight.InnerText = "FALSE";
                    }

                    XmlElement use_for = doc.CreateElement("USE_FOR");
                    use_for.InnerText = txtUseForMiscs.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesMiscs.Text;

                    XmlElement display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "6.50 oz";

                    XmlElement inventory = doc.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 oz";

                    XmlElement display_time = doc.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = "5.0 min";

                    misc.AppendChild(name);
                    misc.AppendChild(version);
                    misc.AppendChild(type);
                    misc.AppendChild(use);
                    misc.AppendChild(amount);
                    misc.AppendChild(time);
                    misc.AppendChild(amount_is_weight);
                    misc.AppendChild(use_for);
                    misc.AppendChild(notes);
                    misc.AppendChild(display_amount);
                    misc.AppendChild(inventory);
                    misc.AppendChild(display_time);

                    miscs.AppendChild(misc);
                    doc.AppendChild(miscs);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  misc";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportMiscs_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Miscs> Miscs = new List<Miscs>();
                Miscs = ul.ListMiscs(doc);
                for (int i = 0; i < Miscs.Count; i++)
                {
                    
                    XmlElement Misc = documentMics.CreateElement("MISC");

                    XmlElement name = documentMics.CreateElement("NAME");
                    name.InnerText = Miscs[i].getNAME().ToString();

                    XmlElement version = documentMics.CreateElement("VERSION");
                    version.InnerText = Miscs[i].getVERSION().ToString();

                    XmlElement type = documentMics.CreateElement("TYPE");
                    type.InnerText = Miscs[i].getTYPE().ToString();

                    XmlElement use = documentMics.CreateElement("USE");
                    use.InnerText = Miscs[i].getUSE().ToString();

                    XmlElement amount = documentMics.CreateElement("AMOUNT");
                    amount.InnerText = Miscs[i].getAMOUNT().ToString();

                    XmlElement time = documentMics.CreateElement("TIME");
                    time.InnerText = Miscs[i].getTIME().ToString();

                    XmlElement amount_is_weight = documentMics.CreateElement("AMOUNT_IS_WEIGHT");
                    amount_is_weight.InnerText = Miscs[i].getAMOUNT_IS_WEIGHT().ToString();

                    XmlElement use_for = documentMics.CreateElement("USE_FOR");
                    use_for.InnerText = Miscs[i].getUSE_FOR().ToString();

                    XmlElement notes = documentMics.CreateElement("NOTES");
                    notes.InnerText = Miscs[i].getNOTES().ToString();

                    XmlElement display_amount = documentMics.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = Miscs[i].getDISPLAY_AMOUNT().ToString();

                    XmlElement inventory = documentMics.CreateElement("INVENTORY");
                    inventory.InnerText = Miscs[i].getINVENTORY().ToString();

                    XmlElement display_time = documentMics.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = Miscs[i].getDISPLAY_TIME().ToString();

                    Misc.AppendChild(name);
                    Misc.AppendChild(version);
                    Misc.AppendChild(type);
                    Misc.AppendChild(use);
                    Misc.AppendChild(amount);
                    Misc.AppendChild(time);
                    Misc.AppendChild(amount_is_weight);
                    Misc.AppendChild(notes);
                    Misc.AppendChild(display_amount);
                    Misc.AppendChild(inventory);
                    Misc.AppendChild(display_time);

                    documentMics.DocumentElement.InsertAfter(Misc, documentMics.DocumentElement.LastChild);
                    try
                    {
                        fsMisc = new FileStream(fileMisc, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentMics.Save(fsMisc);
                    message.title = "Import misc";
                    message.Content = "Import success";
                    message.ShowDialog();
                    
                }
                loadMiscs();
                fsPath.Close();
            }
        }

        private void tableMisc_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameMiscs.Text = tableViewMisc.GetFocusedDataRow()["name"].ToString();
                cbbTypeMiscs.Text = tableViewMisc.GetFocusedDataRow()["type"].ToString();
                cbbUseMiscs.Text = tableViewMisc.GetFocusedDataRow()["use"].ToString();
                txtTimeMiscs.Text = tableViewMisc.GetFocusedDataRow()["time"].ToString() + " s";
                txtAmountMiscs.Text = tableViewMisc.GetFocusedDataRow()["amount"].ToString() + " mg";
                var amount_is_weight = tableViewMisc.GetFocusedDataRow()["amount_is_weight"].ToString();
                if (amount_is_weight == "TRUE")
                {
                    cbAmountIsWeightMiscs.Checked = true;
                }
                else
                {
                    cbAmountIsWeightMiscs.Checked = false;
                }
                txtUseForMiscs.Text = tableViewMisc.GetFocusedDataRow()["use_for"].ToString();
                txtNotesMiscs.Text = tableViewMisc.GetFocusedDataRow()["notes"].ToString();
            }
            catch (Exception) { }
        }

        //Hop
        private void btnNewHops_Click(object sender, EventArgs e)
        {
            txtNameHops.Text = "";
            txtAlphaHops.Text = "0.000";
            txtAmountHops.Text = "0.000 mg";
            cbbUseHops.Text = "";
            txtTimeHops.Text = "";
            cbbTypeHops.Text = "";
            cbbFormHops.Text = "";
            txtBetaHops.Text = "0.000";
            txtHSIHops.Text = "0.000";
            txtOriginHops.Text = "";
            txtHumuleneHops.Text = "0.000";
            txtCaryophylleneHops.Text = "0.000";
            txtCohumuloneHops.Text = "0.000";
            txtMyrceneHops.Text = "0.000";
            txtSubstitutesHops.Text = "";
            txtNotesHops.Text = "";
        }

        private void btnSaveHops_Click(object sender, EventArgs e)
        {
            if (txtNameHops.Text == "")
            {
                message.title = "Error";
                message.Content = "Hop name not null";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentHop.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::HOP[NAME='" + txtNameHops.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = txtOriginHops.Text;
                    node.ChildNodes[3].InnerText = txtAlphaHops.Text;
                    node.ChildNodes[4].InnerText = txtAmountHops.Text.Replace("mg","");
                    node.ChildNodes[5].InnerText = cbbUseHops.Text;
                    node.ChildNodes[6].InnerText = txtTimeHops.Text.Replace("s", "");
                    node.ChildNodes[7].InnerText = txtNotesHops.Text;
                    node.ChildNodes[8].InnerText = cbbTypeHops.Text;
                    node.ChildNodes[9].InnerText = cbbFormHops.Text;
                    node.ChildNodes[10].InnerText = txtBetaHops.Text;
                    node.ChildNodes[11].InnerText = txtHSIHops.Text;
                    node.ChildNodes[12].InnerText = "0.00 oz";
                    node.ChildNodes[13].InnerText = "0.00 oz";
                    node.ChildNodes[14].InnerText = "-";
                    try
                    {
                        fsHops = new FileStream(fileHops, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    documentHop.Save(fsHops);
                    message.title = "Update Hop";
                    message.Content = "Update success";
                    message.ShowDialog();
                    fsHops.Close();
                }
                else
                {
                    XmlElement hop = documentHop.CreateElement("HOP");

                    XmlElement name = documentHop.CreateElement("NAME");
                    name.InnerText = txtNameHops.Text;

                    XmlElement version = documentHop.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement origin = documentHop.CreateElement("ORIGIN");
                    origin.InnerText = txtOriginHops.Text;

                    XmlElement alpha = documentHop.CreateElement("ALPHA");
                    alpha.InnerText = txtAlphaHops.Text;

                    XmlElement amount = documentHop.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountHops.Text.Replace("mg","");

                    XmlElement use = documentHop.CreateElement("USE");
                    use.InnerText = cbbUseHops.Text;

                    XmlElement time = documentHop.CreateElement("TIME");
                    time.InnerText = txtTimeHops.Text.Replace("s","");

                    XmlElement notes = documentHop.CreateElement("NOTES");
                    notes.InnerText = txtNotesHops.Text;

                    XmlElement type = documentHop.CreateElement("TYPE");
                    type.InnerText = cbbTypeHops.Text;

                    XmlElement form = documentHop.CreateElement("FORM");
                    form.InnerText = cbbFormHops.Text;

                    XmlElement beta = documentHop.CreateElement("BETA");
                    beta.InnerText = txtBetaHops.Text;

                    XmlElement hsi = documentHop.CreateElement("HSI");
                    hsi.InnerText = txtHSIHops.Text;

                    XmlElement display_amount = documentHop.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 oz";

                    XmlElement inventory = documentHop.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 oz";

                    XmlElement display_time = documentHop.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = "-";

                    hop.AppendChild(name);
                    hop.AppendChild(version);
                    hop.AppendChild(origin);
                    hop.AppendChild(alpha);
                    hop.AppendChild(amount);
                    hop.AppendChild(use);
                    hop.AppendChild(time);
                    hop.AppendChild(notes);
                    hop.AppendChild(type);
                    hop.AppendChild(form);
                    hop.AppendChild(beta);
                    hop.AppendChild(hsi);
                    hop.AppendChild(display_amount);
                    hop.AppendChild(inventory);
                    hop.AppendChild(display_time);

                    documentHop.DocumentElement.AppendChild(hop);
                    try
                    {
                        fsHops = new FileStream(fileHops, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    documentHop.Save(fsHops);

                    message.title = "Save Hop";
                    message.Content = "Save success";
                    message.ShowDialog();
                    fsHops.Close();
                }
                loadHops();
            }
        }

        private void btnDeleteHops_Click(object sender, EventArgs e)
        {
            if (txtNameHops.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select hop";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentHop.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::HOP[NAME='" + txtNameHops.Text + "']");
                if (node != null)
                {
                    documentHop.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsHops = new FileStream(fileHops, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentHop.Save(fsHops);
                message.title = "Delete Hop";
                message.Content = "Delete success";
                message.ShowDialog();
                loadHops();
                fsHops.Close();
            }
        }

        private void btnExportHops_Click(object sender, EventArgs e)
        {
            if (txtNameHops.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select hop";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement hops = doc.CreateElement("HOPS");

                    XmlElement hop = doc.CreateElement("HOP");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameHops.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement origin = doc.CreateElement("ORIGIN");
                    origin.InnerText = txtOriginHops.Text;

                    XmlElement alpha = doc.CreateElement("ALPHA");
                    alpha.InnerText = txtAlphaHops.Text;

                    XmlElement amount = doc.CreateElement("AMOUNT");
                    amount.InnerText = txtAmountHops.Text;

                    XmlElement use = doc.CreateElement("USE");
                    use.InnerText = cbbUseHops.Text;

                    XmlElement time = doc.CreateElement("TIME");
                    time.InnerText = txtTimeHops.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesHops.Text;

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = cbbTypeHops.Text;

                    XmlElement form = doc.CreateElement("FORM");
                    form.InnerText = cbbFormHops.Text;

                    XmlElement beta = doc.CreateElement("BETA");
                    beta.InnerText = txtBetaHops.Text;

                    XmlElement hsi = doc.CreateElement("HSI");
                    hsi.InnerText = txtHSIHops.Text;

                    XmlElement display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = "0.00 oz";

                    XmlElement inventory = doc.CreateElement("INVENTORY");
                    inventory.InnerText = "0.00 oz";

                    XmlElement display_time = doc.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = "-";

                    hop.AppendChild(name);
                    hop.AppendChild(version);
                    hop.AppendChild(origin);
                    hop.AppendChild(alpha);
                    hop.AppendChild(amount);
                    hop.AppendChild(use);
                    hop.AppendChild(time);
                    hop.AppendChild(notes);
                    hop.AppendChild(type);
                    hop.AppendChild(form);
                    hop.AppendChild(beta);
                    hop.AppendChild(hsi);
                    hop.AppendChild(display_amount);
                    hop.AppendChild(inventory);
                    hop.AppendChild(display_time);
                    hops.AppendChild(hop);
                    doc.AppendChild(hops);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  hop";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportHops_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Hops> Hops = new List<Hops>();
                Hops = ul.ListHops(doc);
                for (int i = 0; i < Hops.Count; i++)
                {
                    
                    XmlElement Hop = documentHop.CreateElement("HOP");

                    XmlElement name = documentHop.CreateElement("NAME");
                    name.InnerText = Hops[i].getNAME().ToString();

                    XmlElement version = documentHop.CreateElement("VERSION");
                    version.InnerText = Hops[i].getVERSION().ToString();

                    XmlElement origin = documentHop.CreateElement("ORIGIN");
                    origin.InnerText = Hops[i].getORIGIN().ToString();

                    XmlElement alpha = documentHop.CreateElement("ALPHA");
                    alpha.InnerText = Hops[i].getALPHA().ToString();

                    XmlElement amount = documentHop.CreateElement("AMOUNT");
                    amount.InnerText = Hops[i].getAMOUNT().ToString();

                    XmlElement use = documentHop.CreateElement("USE");
                    use.InnerText = Hops[i].getUSE().ToString();

                    XmlElement time = documentHop.CreateElement("TIME");
                    time.InnerText = Hops[i].getTIME().ToString();

                    XmlElement notes = documentHop.CreateElement("NOTES");
                    notes.InnerText = Hops[i].getNOTES().ToString();

                    XmlElement type = documentHop.CreateElement("TYPE");
                    type.InnerText = Hops[i].getTYPE().ToString();

                    XmlElement form = documentHop.CreateElement("FORM");
                    form.InnerText = Hops[i].getFORM().ToString();

                    XmlElement beta = documentHop.CreateElement("BETA");
                    beta.InnerText = Hops[i].getBETA().ToString();

                    XmlElement hsi = documentHop.CreateElement("HSI");
                    hsi.InnerText = Hops[i].getHSI().ToString();

                    XmlElement display_amount = documentHop.CreateElement("DISPLAY_AMOUNT");
                    display_amount.InnerText = Hops[i].getDISPLAY_AMOUNT().ToString();

                    XmlElement inventory = documentHop.CreateElement("INVENTORY");
                    inventory.InnerText = Hops[i].getINVENTORY().ToString();

                    XmlElement display_time = documentHop.CreateElement("DISPLAY_TIME");
                    display_time.InnerText = Hops[i].getDISPLAY_TIME().ToString();

                    Hop.AppendChild(name);
                    Hop.AppendChild(version);
                    Hop.AppendChild(origin);
                    Hop.AppendChild(alpha);
                    Hop.AppendChild(amount);
                    Hop.AppendChild(use);
                    Hop.AppendChild(time);
                    Hop.AppendChild(notes);
                    Hop.AppendChild(type);
                    Hop.AppendChild(form);
                    Hop.AppendChild(beta);
                    Hop.AppendChild(hsi);
                    Hop.AppendChild(display_amount);
                    Hop.AppendChild(inventory);
                    Hop.AppendChild(display_time);

                    documentHop.DocumentElement.InsertAfter(Hop, documentHop.DocumentElement.LastChild);
                    try
                    {
                        fsHops = new FileStream(fileHops, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentHop.Save(fsHops);
                    message.title = "Import hop";
                    message.Content = "Import success";
                    message.ShowDialog();
                }
                loadHops();
                fsPath.Close();
            }
        }

        private void tableHop_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameHops.Text = tableViewHop.GetFocusedDataRow()["name"].ToString();
                txtAlphaHops.Text = tableViewHop.GetFocusedDataRow()["alpha"].ToString();
                txtAmountHops.Text = tableViewHop.GetFocusedDataRow()["amount"].ToString() + " mg";
                cbbUseHops.Text = tableViewHop.GetFocusedDataRow()["use"].ToString();
                txtTimeHops.Text = tableViewHop.GetFocusedDataRow()["time"].ToString() + " s";
                cbbTypeHops.Text = tableViewHop.GetFocusedDataRow()["type"].ToString();
                cbbFormHops.Text = tableViewHop.GetFocusedDataRow()["form"].ToString();
                txtBetaHops.Text = tableViewHop.GetFocusedDataRow()["beta"].ToString();
                txtHSIHops.Text = tableViewHop.GetFocusedDataRow()["hsi"].ToString();
                txtOriginHops.Text = tableViewHop.GetFocusedDataRow()["origin"].ToString();
                //txtHumuleneHops.Text = "";
                //txtCaryophylleneHops.Text = "";
                //txtCohumuloneHops.Text = "";
                //txtMyrceneHops.Text = "";
                //txtSubstitutesHops.Text = "";
                txtNotesHops.Text = tableViewHop.GetFocusedDataRow()["notes"].ToString();


            }
            catch (Exception) { }
        }

        //Equipment
        private void btnNewEquipment_Click(object sender, EventArgs e)
        {
            txtNameEquipment.Text = "";
            txtPreBoilVolumeEquipment.Text = "0.000 mL";
            cbCalculatePreBoilVolumeEquipment.Checked = false;
            txtBatchSizeEquipment.Text = "0.000 mL";
            txtBoilTimeEquipment.Text = "0.000 s";
            txtEvaporationRateEquipment.Text = "0.000 mL";
            txtKettleTopUpWaterEquipment.Text = "0.000 mL";
            txtFinalTopUpWaterEquipment.Text = "0.000 mL";
            txtGrainAbsorptionEquipment.Text = "1.085";
            txtBoilTimeEquipment.Text = "100.000 C";
            txtHopUtilizationEquipment.Text = "0.0";
            txtVolumeEquipment.Text = "0.000 mL";
            txtMassEquipment.Text = "0.000 mg";
            txtSpecifictHeatEquipment.Text = "0.000";
            txtKettleToFermenterEquipment.Text = "0.000 mL";
            txtLauterDeadspaceEquipment.Text = "0.000 mL";
            txtNotesEquipment.Text = "";

        }

        private void btnSaveEquipment_Click(object sender, EventArgs e)
        {
            XmlNode root = documentEquipment.DocumentElement;
            XmlNode node = root.SelectSingleNode("descendant::EQUIPMENT[NAME='" + txtNameEquipment.Text + "']");
            if (node != null)
            {
                node.ChildNodes[1].InnerText = "1";
                node.ChildNodes[2].InnerText = txtPreBoilVolumeEquipment.Text.Replace("mL", "");
                node.ChildNodes[3].InnerText = txtBatchSizeEquipment.Text.Replace("mL", "");
                node.ChildNodes[4].InnerText = txtVolumeEquipment.Text.Replace("mL", "");
                node.ChildNodes[5].InnerText = txtMassEquipment.Text.Replace("mg", "");
                node.ChildNodes[6].InnerText = txtSpecifictHeatEquipment.Text;
                node.ChildNodes[7].InnerText = txtFinalTopUpWaterEquipment.Text.Replace("Ml", "");
                node.ChildNodes[8].InnerText = "0.0000";
                node.ChildNodes[9].InnerText = txtEvaporationRateEquipment.Text.Replace("mL", "");
                node.ChildNodes[10].InnerText = txtBoilTimeEquipment.Text.Replace("s", "");
                if (cbCalculatePreBoilVolumeEquipment.Checked)
                {
                    node.ChildNodes[11].InnerText = "TRUE";
                }
                else
                {
                    node.ChildNodes[11].InnerText = "FALSE";
                }
                node.ChildNodes[12].InnerText = txtLauterDeadspaceEquipment.Text.Replace("mL", "");
                node.ChildNodes[13].InnerText = txtKettleTopUpWaterEquipment.Text.Replace("mL", "");
                node.ChildNodes[14].InnerText = txtHopUtilizationEquipment.Text;
                node.ChildNodes[15].InnerText = txtNotesEquipment.Text;
                node.ChildNodes[16].InnerText = "3.25 gal";
                node.ChildNodes[17].InnerText = "5.00 gal";
                node.ChildNodes[18].InnerText = "4.00 gal";
                node.ChildNodes[19].InnerText = "4.00 lb";
                node.ChildNodes[20].InnerText = "2.25 gal";
                node.ChildNodes[21].InnerText = "0.00 gal";
                node.ChildNodes[22].InnerText = "0.25 gal";
                node.ChildNodes[23].InnerText = "0.00 gal";

                try
                {
                    fsEquipment = new FileStream(fileEquipment, FileMode.OpenOrCreate);
                }
                catch (Exception) { }
                documentEquipment.Save(fsEquipment);
                message.title = "Update Equipment";
                message.Content = "Update success";
                message.ShowDialog();
                fsEquipment.Close();
            }
            else
            {
                XmlElement equipment = documentEquipment.CreateElement("EQUIPMENT");

                XmlElement name = documentEquipment.CreateElement("NAME");
                name.InnerText = txtNameEquipment.Text;

                XmlElement version = documentEquipment.CreateElement("VERSION");
                version.InnerText = "1";

                XmlElement boil_size = documentEquipment.CreateElement("BOIL_SIZE");
                boil_size.InnerText = txtPreBoilVolumeEquipment.Text.Replace("mL", "");

                XmlElement batch_size = documentEquipment.CreateElement("BATCH_SIZE");
                batch_size.InnerText = txtBatchSizeEquipment.Text.Replace("mL", "");

                XmlElement tun_volume = documentEquipment.CreateElement("TUN_VOLUME");
                tun_volume.InnerText = txtVolumeEquipment.Text.Replace("mL", "");

                XmlElement tun_weight = documentEquipment.CreateElement("TUN_WEIGHT");
                tun_weight.InnerText = txtMassEquipment.Text.Replace("mg", "");

                XmlElement tun_specific_heat = documentEquipment.CreateElement("TUN_SPECIFIC_HEAT");
                tun_specific_heat.InnerText = txtSpecifictHeatEquipment.Text;

                XmlElement top_up_water = documentEquipment.CreateElement("TOP_UP_WATER");
                top_up_water.InnerText = txtFinalTopUpWaterEquipment.Text.Replace("Ml", "");

                XmlElement trub_chiller_loss = documentEquipment.CreateElement("TRUB_CHILLER_LOSS");
                trub_chiller_loss.InnerText = "0.0000";

                XmlElement evap_rate = documentEquipment.CreateElement("EVAP_RATE");
                evap_rate.InnerText = txtEvaporationRateEquipment.Text.Replace("mL", "");

                XmlElement boil_time = documentEquipment.CreateElement("BOIL_TIME");
                boil_time.InnerText = txtBoilTimeEquipment.Text.Replace("s", "");

                XmlElement calc_boil_volume = documentEquipment.CreateElement("CALC_BOIL_VOLUME");
                if (cbCalculatePreBoilVolumeEquipment.Checked)
                {
                    calc_boil_volume.InnerText = "TRUE";
                }
                else
                {
                    calc_boil_volume.InnerText = "FALSE";
                }

                XmlElement lauter_deadspace = documentEquipment.CreateElement("LAUTER_DEADSPACE");
                lauter_deadspace.InnerText = txtLauterDeadspaceEquipment.Text.Replace("mL", "");

                XmlElement top_up_kettle = documentEquipment.CreateElement("TOP_UP_KETTLE");
                top_up_kettle.InnerText = txtKettleTopUpWaterEquipment.Text.Replace("mL", "");

                XmlElement hop_utlization = documentEquipment.CreateElement("HOP_UTILIZATION");
                hop_utlization.InnerText = txtHopUtilizationEquipment.Text;

                XmlElement notes = documentEquipment.CreateElement("NOTES");
                notes.InnerText = txtNotesEquipment.Text;

                XmlElement display_boil_size = documentEquipment.CreateElement("DISPLAY_BOIL_SIZE");
                display_boil_size.InnerText = "3.25 gal";

                XmlElement display_batch_size = documentEquipment.CreateElement("DISPLAY_BATCH_SIZE");
                display_batch_size.InnerText = "5.00 gal";

                XmlElement display_tun_volume = documentEquipment.CreateElement("DISPLAY_TUN_VOLUME");
                display_tun_volume.InnerText = "4.00 gal";

                XmlElement display_tun_weight = documentEquipment.CreateElement("DISPLAY_TUN_WEIGHT");
                display_tun_weight.InnerText = "4.00 lb";

                XmlElement display_top_up_water = documentEquipment.CreateElement("DISPLAY_TOP_UP_WATER");
                display_top_up_water.InnerText = "2.25 gal";

                XmlElement display_trub_chiller_loss = documentEquipment.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                display_trub_chiller_loss.InnerText = "0.00 gal";

                XmlElement display_lauter_deadspace = documentEquipment.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                display_lauter_deadspace.InnerText = "0.25 gal";

                XmlElement display_top_kettle = documentEquipment.CreateElement("DISPLAY_TOP_UP_KETTLE");
                display_top_kettle.InnerText = "0.00 gal";

                equipment.AppendChild(name);
                equipment.AppendChild(version);
                equipment.AppendChild(boil_size);
                equipment.AppendChild(batch_size);
                equipment.AppendChild(tun_volume);
                equipment.AppendChild(tun_weight);
                equipment.AppendChild(tun_specific_heat);
                equipment.AppendChild(top_up_water);
                equipment.AppendChild(trub_chiller_loss);
                equipment.AppendChild(evap_rate);
                equipment.AppendChild(boil_time);
                equipment.AppendChild(calc_boil_volume);
                equipment.AppendChild(lauter_deadspace);
                equipment.AppendChild(top_up_kettle);
                equipment.AppendChild(hop_utlization);
                equipment.AppendChild(notes);
                equipment.AppendChild(display_boil_size);
                equipment.AppendChild(display_batch_size);
                equipment.AppendChild(display_tun_volume);
                equipment.AppendChild(display_tun_weight);
                equipment.AppendChild(display_top_up_water);
                equipment.AppendChild(display_trub_chiller_loss);
                equipment.AppendChild(display_lauter_deadspace);
                equipment.AppendChild(display_top_kettle);

                documentEquipment.DocumentElement.AppendChild(equipment);

                try
                {
                    fsEquipment = new FileStream(fileEquipment, FileMode.OpenOrCreate);
                }
                catch (Exception) { }
                XmlTextWriter writer = new XmlTextWriter(fsEquipment, null);
                writer.Formatting = Formatting.Indented;
                documentEquipment.Save(writer);

                message.title = "Save Equipment";
                message.Content = "Save success";
                message.ShowDialog();
                fsEquipment.Close();
            }
            loadEquipment();
        }

        private void btnDeleteEquipment_Click(object sender, EventArgs e)
        {
            if (txtNameEquipment.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select equipment";
                message.ShowDialog();
            }
            else
            {

                XmlNode root = documentEquipment.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::EQUIPMENT[NAME='" + txtNameEquipment.Text + "']");
                if (node != null)
                {
                    documentEquipment.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsEquipment = new FileStream(fileEquipment, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentEquipment.Save(fsEquipment);
                message.title = "Delete Equipment";
                message.Content = "Delete success";
                message.ShowDialog();
                loadEquipment();
                fsEquipment.Close();
            }
        }

        private void btnExportEquipment_Click(object sender, EventArgs e)
        {
            if (txtNameEquipment.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select equipment";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement equipments = doc.CreateElement("EQUIPMENTS");

                    XmlElement equipment = doc.CreateElement("EQUIPMENT");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameEquipment.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement boil_size = doc.CreateElement("BOIL_SIZE");
                    boil_size.InnerText = txtPreBoilVolumeEquipment.Text.Replace("mL", "");

                    XmlElement batch_size = doc.CreateElement("BATCH_SIZE");
                    batch_size.InnerText = txtBatchSizeEquipment.Text.Replace("mL", "");

                    XmlElement tun_volume = doc.CreateElement("TUN_VOLUME");
                    tun_volume.InnerText = txtVolumeEquipment.Text.Replace("mL", "");

                    XmlElement tun_weight = doc.CreateElement("TUN_WEIGHT");
                    tun_weight.InnerText = txtMassEquipment.Text.Replace("mg", "");

                    XmlElement tun_specific_heat = doc.CreateElement("TUN_SPECIFIC_HEAT");
                    tun_specific_heat.InnerText = txtSpecifictHeatEquipment.Text;

                    XmlElement top_up_water = doc.CreateElement("TOP_UP_WATER");
                    top_up_water.InnerText = txtFinalTopUpWaterEquipment.Text.Replace("Ml", "");

                    XmlElement trub_chiller_loss = doc.CreateElement("TRUB_CHILLER_LOSS");
                    trub_chiller_loss.InnerText = "0.0000";

                    XmlElement evap_rate = doc.CreateElement("EVAP_RATE");
                    evap_rate.InnerText = txtEvaporationRateEquipment.Text.Replace("mL", "");

                    XmlElement boil_time = doc.CreateElement("BOIL_TIME");
                    boil_time.InnerText = txtBoilTimeEquipment.Text.Replace("s", "");

                    XmlElement calc_boil_volume = doc.CreateElement("CALC_BOIL_VOLUME");
                    if (cbCalculatePreBoilVolumeEquipment.Checked)
                    {
                        calc_boil_volume.InnerText = "TRUE";
                    }
                    else
                    {
                        calc_boil_volume.InnerText = "FALSE";
                    }

                    XmlElement lauter_deadspace = doc.CreateElement("LAUTER_DEADSPACE");
                    lauter_deadspace.InnerText = txtLauterDeadspaceEquipment.Text.Replace("mL", "");

                    XmlElement top_up_kettle = doc.CreateElement("TOP_UP_KETTLE");
                    top_up_kettle.InnerText = txtKettleTopUpWaterEquipment.Text.Replace("mL", "");

                    XmlElement hop_utlization = doc.CreateElement("HOP_UTILIZATION");
                    hop_utlization.InnerText = txtHopUtilizationEquipment.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesEquipment.Text;

                    XmlElement display_boil_size = doc.CreateElement("DISPLAY_BOIL_SIZE");
                    display_boil_size.InnerText = "3.25 gal";

                    XmlElement display_batch_size = doc.CreateElement("DISPLAY_BATCH_SIZE");
                    display_batch_size.InnerText = "5.00 gal";

                    XmlElement display_tun_volume = doc.CreateElement("DISPLAY_TUN_VOLUME");
                    display_tun_volume.InnerText = "4.00 gal";

                    XmlElement display_tun_weight = doc.CreateElement("DISPLAY_TUN_WEIGHT");
                    display_tun_weight.InnerText = "4.00 lb";

                    XmlElement display_top_up_water = doc.CreateElement("DISPLAY_TOP_UP_WATER");
                    display_top_up_water.InnerText = "2.25 gal";

                    XmlElement display_trub_chiller_loss = doc.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    display_trub_chiller_loss.InnerText = "0.00 gal";

                    XmlElement display_lauter_deadspace = doc.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    display_lauter_deadspace.InnerText = "0.25 gal";

                    XmlElement display_top_kettle = doc.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    display_top_kettle.InnerText = "0.00 gal";

                    equipment.AppendChild(name);
                    equipment.AppendChild(version);
                    equipment.AppendChild(boil_size);
                    equipment.AppendChild(batch_size);
                    equipment.AppendChild(tun_volume);
                    equipment.AppendChild(tun_weight);
                    equipment.AppendChild(tun_specific_heat);
                    equipment.AppendChild(top_up_water);
                    equipment.AppendChild(trub_chiller_loss);
                    equipment.AppendChild(evap_rate);
                    equipment.AppendChild(boil_time);
                    equipment.AppendChild(calc_boil_volume);
                    equipment.AppendChild(lauter_deadspace);
                    equipment.AppendChild(top_up_kettle);
                    equipment.AppendChild(hop_utlization);
                    equipment.AppendChild(notes);
                    equipment.AppendChild(display_boil_size);
                    equipment.AppendChild(display_batch_size);
                    equipment.AppendChild(display_tun_volume);
                    equipment.AppendChild(display_tun_weight);
                    equipment.AppendChild(display_top_up_water);
                    equipment.AppendChild(display_trub_chiller_loss);
                    equipment.AppendChild(display_lauter_deadspace);
                    equipment.AppendChild(display_top_kettle);

                    equipments.AppendChild(equipment);

                    doc.AppendChild(equipments);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  equipment";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportEquipment_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Equipments> Equipments = new List<Equipments>();
                Equipments = ul.ListEquipments(doc);
                for (int i = 0; i < Equipments.Count; i++)
                {
                    XmlElement Equipment = documentEquipment.CreateElement("EQUIPMENT");

                    XmlElement name = documentEquipment.CreateElement("NAME");
                    name.InnerText = Equipments[i].getNAME().ToString();

                    XmlElement version = documentEquipment.CreateElement("VERSION");
                    version.InnerText = Equipments[i].getVERSION().ToString();

                    XmlElement boil_size = documentEquipment.CreateElement("BOIL_SIZE");
                    boil_size.InnerText = Equipments[i].getBOIL_SIZE().ToString().Replace("mL","");

                    XmlElement batch_size = documentEquipment.CreateElement("BATCH_SIZE");
                    batch_size.InnerText = Equipments[i].getBATCH_SIZE().ToString().Replace("mL", "");

                    XmlElement tun_volume = documentEquipment.CreateElement("TUN_VOLUME");
                    tun_volume.InnerText = Equipments[i].getTUN_VOLUME().ToString().Replace("mL", "");

                    XmlElement tun_weight = documentEquipment.CreateElement("TUN_WEIGHT");
                    tun_weight.InnerText = Equipments[i].getTUN_WEIGHT().ToString().Replace("mg", "");

                    XmlElement tun_specific_heat = documentEquipment.CreateElement("TUN_SPECIFIC_HEAT");
                    tun_specific_heat.InnerText = Equipments[i].getTUN_SPECIFIC_HEAT().ToString();

                    XmlElement top_up_water = documentEquipment.CreateElement("TOP_UP_WATER");
                    top_up_water.InnerText = Equipments[i].getTOP_UP_WATER().ToString().Replace("Ml", "");

                    XmlElement trub_chiller_loss = documentEquipment.CreateElement("TRUB_CHILLER_LOSS");
                    trub_chiller_loss.InnerText = Equipments[i].getTRUB_CHILLER_LOSS().ToString();

                    XmlElement evap_rate = documentEquipment.CreateElement("EVAP_RATE");
                    evap_rate.InnerText = Equipments[i].getEVAP_RATE().ToString().Replace("mL", "");

                    XmlElement boil_time = documentEquipment.CreateElement("BOIL_TIME");
                    boil_time.InnerText = Equipments[i].getBOIL_TIME().ToString().Replace("s", "");

                    XmlElement calc_boil_volume = documentEquipment.CreateElement("CALC_BOIL_VOLUME");
                    calc_boil_volume.InnerText = Equipments[i].getCALC_BOIL_VOLUME().ToString();

                    XmlElement lauter_deadspace = documentEquipment.CreateElement("LAUTER_DEADSPACE");
                    lauter_deadspace.InnerText = Equipments[i].getLAUTER_DEADSPACE().ToString().Replace("mL", "");

                    XmlElement top_up_kettle = documentEquipment.CreateElement("TOP_UP_KETTLE");
                    top_up_kettle.InnerText = Equipments[i].getTOP_UP_KETTLE().ToString().Replace("mL", "");

                    XmlElement hop_utlization = documentEquipment.CreateElement("HOP_UTILIZATION");
                    hop_utlization.InnerText = Equipments[i].getHOP_UTILIZATION().ToString();

                    XmlElement notes = documentEquipment.CreateElement("NOTES");
                    notes.InnerText = Equipments[i].getNOTES().ToString();

                    XmlElement display_boil_size = documentEquipment.CreateElement("DISPLAY_BOIL_SIZE");
                    display_boil_size.InnerText = Equipments[i].getDISPLAY_BOIL_SIZE().ToString();

                    XmlElement display_batch_size = documentEquipment.CreateElement("DISPLAY_BATCH_SIZE");
                    display_batch_size.InnerText = Equipments[i].getDISPLAY_BATCH_SIZE().ToString();

                    XmlElement display_tun_volume = documentEquipment.CreateElement("DISPLAY_TUN_VOLUME");
                    display_tun_volume.InnerText = Equipments[i].getDISPLAY_TUN_VOLUME().ToString();

                    XmlElement display_tun_weight = documentEquipment.CreateElement("DISPLAY_TUN_WEIGHT");
                    display_tun_weight.InnerText = Equipments[i].getDISPLAY_TUN_WEIGHT().ToString();

                    XmlElement display_top_up_water = documentEquipment.CreateElement("DISPLAY_TOP_UP_WATER");
                    display_top_up_water.InnerText = Equipments[i].getDISPLAY_TOP_UP_WATER().ToString();

                    XmlElement display_trub_chiller_loss = documentEquipment.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    display_trub_chiller_loss.InnerText = Equipments[i].getDISPLAY_TRUB_CHILLER_LOSS().ToString();

                    XmlElement display_lauter_deadspace = documentEquipment.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    display_lauter_deadspace.InnerText = Equipments[i].getDISPLAY_LAUTER_DEADSPACE().ToString();

                    XmlElement display_top_kettle = documentEquipment.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    display_top_kettle.InnerText = Equipments[i].getDISPLAY_TOP_UP_KETTLE().ToString();

                    Equipment.AppendChild(name);
                    Equipment.AppendChild(version);
                    Equipment.AppendChild(boil_size);
                    Equipment.AppendChild(batch_size);
                    Equipment.AppendChild(tun_volume);
                    Equipment.AppendChild(tun_weight);
                    Equipment.AppendChild(tun_specific_heat);
                    Equipment.AppendChild(top_up_water);
                    Equipment.AppendChild(trub_chiller_loss);
                    Equipment.AppendChild(evap_rate);
                    Equipment.AppendChild(boil_time);
                    Equipment.AppendChild(calc_boil_volume);
                    Equipment.AppendChild(lauter_deadspace);
                    Equipment.AppendChild(top_up_kettle);
                    Equipment.AppendChild(hop_utlization);
                    Equipment.AppendChild(notes);
                    Equipment.AppendChild(display_boil_size);
                    Equipment.AppendChild(display_batch_size);
                    Equipment.AppendChild(display_tun_volume);
                    Equipment.AppendChild(display_tun_weight);
                    Equipment.AppendChild(display_top_up_water);
                    Equipment.AppendChild(display_trub_chiller_loss);
                    Equipment.AppendChild(display_lauter_deadspace);
                    Equipment.AppendChild(display_top_kettle);

                    documentEquipment.DocumentElement.InsertAfter(Equipment, documentEquipment.DocumentElement.LastChild);
                    try
                    {
                        fsEquipment = new FileStream(fileEquipment, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentEquipment.Save(fsEquipment);
                    message.title = "Import  equipment";
                    message.Content = "Import success";
                    message.ShowDialog();
                }
                loadEquipment();
                fsPath.Close();
            }
        }

        private void tableEquipment_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameEquipment.Text = tableViewEquipment.GetFocusedDataRow()["name"].ToString();
                //txtPreBoilVolumeEquipment.Text = tableViewEquipment.GetFocusedDataRow()["name"].ToString();
                var calculatepreboilvolume = tableViewEquipment.GetFocusedDataRow()["calc_boil_volume"].ToString();
                if (calculatepreboilvolume == "TRUE")
                {
                    cbCalculatePreBoilVolumeEquipment.Checked = true;
                }
                else
                {
                    cbCalculatePreBoilVolumeEquipment.Checked = false;
                }
                txtBatchSizeEquipment.Text = tableViewEquipment.GetFocusedDataRow()["batch_size"].ToString() + " mL";
                txtBoilTimeEquipment.Text = tableViewEquipment.GetFocusedDataRow()["boil_time"].ToString() + "s";
                txtEvaporationRateEquipment.Text = tableViewEquipment.GetFocusedDataRow()["evap_rate"].ToString() + " mL";
                txtKettleTopUpWaterEquipment.Text = tableViewEquipment.GetFocusedDataRow()["top_up_water"].ToString() + " mL";
                txtFinalTopUpWaterEquipment.Text = tableViewEquipment.GetFocusedDataRow()["top_up_kettle"].ToString() + " Ml";
                //txtGrainAbsorptionEquipment.Text = tableViewEquipment.GetFocusedDataRow()["top_up_kettle"].ToString();
                //tBoilingPointOfWaterEquipment.Text = "";
                txtHopUtilizationEquipment.Text = tableViewEquipment.GetFocusedDataRow()["hop_utilization"].ToString();
                txtVolumeEquipment.Text = tableViewEquipment.GetFocusedDataRow()["tun_volume"].ToString() + "mL";
                txtMassEquipment.Text = tableViewEquipment.GetFocusedDataRow()["tun_weight"].ToString() + "mg";
                txtSpecifictHeatEquipment.Text = tableViewEquipment.GetFocusedDataRow()["tun_specific_head"].ToString();
                //txtKettleToFermenterEquipment.Text = tableViewEquipment.GetFocusedDataRow()["tun_specific_head"].ToString();
                txtLauterDeadspaceEquipment.Text = tableViewEquipment.GetFocusedDataRow()["lauter_deadspace"].ToString() + " mL";
                txtNotesEquipment.Text = tableViewEquipment.GetFocusedDataRow()["notes"].ToString();

            }
            catch (Exception) { }
        }

        //Style
        private void btnNewStyles_Click(object sender, EventArgs e)
        {
            txtNameStyles.Text = "";
            txtCategoryStyles.Text = "";
            txtCategoryNumberStyles.Text = "";
            txtStyleLetterStyles.Text = "";
            txtStyleGuideStyles.Text = "";
            cbbTypeStyles.Text = "";
            txtMinOGStyles.Text = "1.000";
            txtMaxOGStyles.Text = "1.100";
            txtMinFGStyles.Text = "1.000";
            txtMaxFGStyles.Text = "1.100";
            txtMinIBUStyles.Text = "0.000";
            txtMaxIBUStyles.Text = "100.000";
            txtMinColorStyles.Text = "0.0";
            txtMaxColorStyles.Text = "100.0";
            txtMinCarbStyles.Text = "0.000";
            txtMaxColorStyles.Text = "100.000";
            txtMinABVStyles.Text = "0.000";
            txtMaxABVStyles.Text = "100.000";
        }

        private void btnSaveStyles_Click(object sender, EventArgs e)
        {
            if (txtNameStyles.Text == "")
            {
                message.title = "Error";
                message.Content = "Style name not null";
                message.ShowDialog();
            }
            else
            {

                XmlNode root = documentStyle.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::STYLE[NAME='" + txtNameStyles.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = txtCategoryStyles.Text;
                    node.ChildNodes[3].InnerText = txtCategoryNumberStyles.Text;
                    node.ChildNodes[4].InnerText = txtStyleLetterStyles.Text;
                    node.ChildNodes[5].InnerText = txtStyleGuideStyles.Text;
                    node.ChildNodes[6].InnerText = cbbTypeStyles.Text;
                    node.ChildNodes[7].InnerText = txtMinOGStyles.Text;
                    node.ChildNodes[8].InnerText = txtMaxOGStyles.Text;
                    node.ChildNodes[9].InnerText = txtMinFGStyles.Text;
                    node.ChildNodes[10].InnerText = txtMaxFGStyles.Text;
                    node.ChildNodes[11].InnerText = txtMinIBUStyles.Text;
                    node.ChildNodes[12].InnerText = txtMaxIBUStyles.Text;
                    node.ChildNodes[13].InnerText = txtMinColorStyles.Text;
                    node.ChildNodes[14].InnerText = txtMaxColorStyles.Text;
                    node.ChildNodes[15].InnerText = txtMinCarbStyles.Text;
                    node.ChildNodes[16].InnerText = txtMaxCarbStyles.Text;
                    node.ChildNodes[17].InnerText = txtMaxABVStyles.Text;
                    node.ChildNodes[18].InnerText = txtMinABVStyles.Text;
                    node.ChildNodes[19].InnerText = txtNotesStyles.Text;
                    node.ChildNodes[20].InnerText = txtProfileStyles.Text;
                    node.ChildNodes[21].InnerText = txtIngredientsStyles.Text;
                    node.ChildNodes[22].InnerText = txtExamplesStyles.Text;
                    node.ChildNodes[23].InnerText = "1.035 SG";
                    node.ChildNodes[24].InnerText = "1.055 SG";
                    node.ChildNodes[25].InnerText = "1.008 SG";
                    node.ChildNodes[26].InnerText = "1.015 SG";
                    node.ChildNodes[27].InnerText = "2.0 SRM";
                    node.ChildNodes[28].InnerText = "8.0 SRM";
                    node.ChildNodes[29].InnerText = "1.035-1.055 SG";
                    node.ChildNodes[30].InnerText = "1.008-1.015 SG";
                    node.ChildNodes[31].InnerText = "10.0-30.0 IBU";
                    node.ChildNodes[32].InnerText = "2.3-2.6 vols";
                    node.ChildNodes[33].InnerText = "2.0-8.0 SRM";
                    node.ChildNodes[34].InnerText = "3.7-5.5 %";

                    try
                    {
                        fsStyle = new FileStream(fileStyle, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    documentStyle.Save(fsStyle);
                    message.title = "Update Style";
                    message.Content = "Update success";
                    message.ShowDialog();
                    fsStyle.Close();
                }
                else
                {
                    XmlElement style = documentStyle.CreateElement("STYLE");

                    XmlElement name = documentStyle.CreateElement("NAME");
                    name.InnerText = txtNameStyles.Text;

                    XmlElement version = documentStyle.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement category = documentStyle.CreateElement("CATEGORY");
                    category.InnerText = txtCategoryStyles.Text;

                    XmlElement category_number = documentStyle.CreateElement("CATEGORY_NUMBER");
                    category_number.InnerText = txtCategoryNumberStyles.Text;

                    XmlElement style_letter = documentStyle.CreateElement("STYLE_LETTER");
                    style_letter.InnerText = txtStyleLetterStyles.Text;

                    XmlElement style_guide = documentStyle.CreateElement("STYLE_GUIDE");
                    style_guide.InnerText = txtStyleGuideStyles.Text;

                    XmlElement type = documentStyle.CreateElement("TYPE");
                    type.InnerText = cbbTypeStyles.Text;

                    XmlElement og_min = documentStyle.CreateElement("OG_MIN");
                    og_min.InnerText = txtMinOGStyles.Text;

                    XmlElement og_max = documentStyle.CreateElement("OG_MAX");
                    og_max.InnerText = txtMaxOGStyles.Text;

                    XmlElement fg_min = documentStyle.CreateElement("FG_MIN");
                    fg_min.InnerText = txtMinFGStyles.Text;

                    XmlElement fg_max = documentStyle.CreateElement("FG_MAX");
                    fg_max.InnerText = txtMaxFGStyles.Text;

                    XmlElement ibu_min = documentStyle.CreateElement("IBU_MIN");
                    ibu_min.InnerText = txtMinIBUStyles.Text;

                    XmlElement ibu_max = documentStyle.CreateElement("IBU_MAX");
                    ibu_max.InnerText = txtMaxIBUStyles.Text;

                    XmlElement color_min = documentStyle.CreateElement("COLOR_MIN");
                    color_min.InnerText = txtMinColorStyles.Text;

                    XmlElement color_max = documentStyle.CreateElement("COLOR_MAX");
                    color_max.InnerText = txtMaxColorStyles.Text;

                    XmlElement carb_min = documentStyle.CreateElement("CARB_MIN");
                    carb_min.InnerText = txtMinCarbStyles.Text;

                    XmlElement carb_max = documentStyle.CreateElement("CARB_MAX");
                    carb_max.InnerText = txtMaxCarbStyles.Text;

                    XmlElement abv_max = documentStyle.CreateElement("ABV_MAX");
                    abv_max.InnerText = txtMaxABVStyles.Text;

                    XmlElement abv_min = documentStyle.CreateElement("ABV_MIN");
                    abv_min.InnerText = txtMinABVStyles.Text;

                    XmlElement notes = documentStyle.CreateElement("NOTES");
                    notes.InnerText = txtNotesStyles.Text;

                    XmlElement profile = documentStyle.CreateElement("PROFILE");
                    profile.InnerText = txtProfileStyles.Text;

                    XmlElement ingredients = documentStyle.CreateElement("INGREDIENTS");
                    ingredients.InnerText = txtIngredientsStyles.Text;

                    XmlElement examples = documentStyle.CreateElement("EXAMPLES");
                    examples.InnerText = txtExamplesStyles.Text;

                    XmlElement display_og_min = documentStyle.CreateElement("DISPLAY_OG_MIN");
                    display_og_min.InnerText = "1.035 SG";

                    XmlElement display_og_max = documentStyle.CreateElement("DISPLAY_OG_MAX");
                    display_og_max.InnerText = "1.055 SG";

                    XmlElement display_fg_min = documentStyle.CreateElement("DISPLAY_FG_MIN");
                    display_fg_min.InnerText = "1.008 SG";

                    XmlElement display_fg_max = documentStyle.CreateElement("DISPLAY_FG_MAX");
                    display_fg_max.InnerText = "1.015 SG";

                    XmlElement display_color_min = documentStyle.CreateElement("DISPLAY_COLOR_MIN");
                    display_color_min.InnerText = "2.0 SRM";

                    XmlElement display_color_max = documentStyle.CreateElement("DISPLAY_COLOR_MAX");
                    display_color_max.InnerText = "8.0 SRM";

                    XmlElement og_range = documentStyle.CreateElement("OG_RANGE");
                    og_range.InnerText = "1.035-1.055 SG";

                    XmlElement fg_range = documentStyle.CreateElement("FG_RANGE");
                    fg_range.InnerText = "1.008-1.015 SG";

                    XmlElement ibu_range = documentStyle.CreateElement("IBU_RANGE");
                    ibu_range.InnerText = "10.0-30.0 IBU";

                    XmlElement carb_range = documentStyle.CreateElement("CARB_RANGE");
                    carb_range.InnerText = "2.3-2.6 vols";

                    XmlElement color_range = documentStyle.CreateElement("COLOR_RANGE");
                    color_range.InnerText = "2.0-8.0 SRM";

                    XmlElement abv_range = documentStyle.CreateElement("ABV_RANGE");
                    abv_range.InnerText = "3.7-5.5 %";

                    style.AppendChild(name);
                    style.AppendChild(version);
                    style.AppendChild(category);
                    style.AppendChild(category_number);
                    style.AppendChild(style_letter);
                    style.AppendChild(style_guide);
                    style.AppendChild(type);
                    style.AppendChild(og_min);
                    style.AppendChild(og_max);
                    style.AppendChild(fg_min);
                    style.AppendChild(fg_max);
                    style.AppendChild(ibu_min);
                    style.AppendChild(ibu_max);
                    style.AppendChild(color_min);
                    style.AppendChild(color_max);
                    style.AppendChild(carb_min);
                    style.AppendChild(carb_max);
                    style.AppendChild(abv_max);
                    style.AppendChild(abv_min);
                    style.AppendChild(notes);
                    style.AppendChild(profile);
                    style.AppendChild(ingredients);
                    style.AppendChild(examples);
                    style.AppendChild(display_og_min);
                    style.AppendChild(display_og_max);
                    style.AppendChild(display_fg_min);
                    style.AppendChild(display_fg_max);
                    style.AppendChild(display_color_min);
                    style.AppendChild(display_color_max);
                    style.AppendChild(og_range);
                    style.AppendChild(fg_range);
                    style.AppendChild(ibu_range);
                    style.AppendChild(carb_range);
                    style.AppendChild(color_range);
                    style.AppendChild(abv_range);


                    documentStyle.DocumentElement.AppendChild(style);
                    try
                    {
                        fsStyle = new FileStream(fileStyle, FileMode.OpenOrCreate);
                    }
                    catch (Exception) { }
                    XmlTextWriter writer = new XmlTextWriter(fsStyle, null);
                    writer.Formatting = Formatting.Indented;
                    documentStyle.Save(writer);

                    message.title = "Save Style";
                    message.Content = "Save success";
                    message.ShowDialog();
                    fsStyle.Close();
                }
                loadStyles();
            }
        }

        private void btnDeleteStyles_Click(object sender, EventArgs e)
        {
            if (txtNameStyles.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select style";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentStyle.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::STYLE[NAME='" + txtNameStyles.Text + "']");
                if (node != null)
                {
                    documentStyle.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsStyle = new FileStream(fileStyle, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentStyle.Save(fsStyle);
                message.title = "Delete Style";
                message.Content = "Delete success";
                message.ShowDialog();
                loadStyles();
                fsStyle.Close();
            }
        }

        private void btnExportStyles_Click(object sender, EventArgs e)
        {
            if (txtNameStyles.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select style";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement styles = doc.CreateElement("STYLES");

                    XmlElement style = doc.CreateElement("STYLE");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameStyles.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement category = doc.CreateElement("CATEGORY");
                    category.InnerText = txtCategoryStyles.Text;

                    XmlElement category_number = doc.CreateElement("CATEGORY_NUMBER");
                    category_number.InnerText = txtCategoryNumberStyles.Text;

                    XmlElement style_letter = doc.CreateElement("STYLE_LETTER");
                    style_letter.InnerText = txtStyleLetterStyles.Text;

                    XmlElement style_guide = doc.CreateElement("STYLE_GUIDE");
                    style_guide.InnerText = txtStyleGuideStyles.Text;

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = cbbTypeStyles.Text;

                    XmlElement og_min = doc.CreateElement("OG_MIN");
                    og_min.InnerText = txtMinOGStyles.Text;

                    XmlElement og_max = doc.CreateElement("OG_MAX");
                    og_max.InnerText = txtMaxOGStyles.Text;

                    XmlElement fg_min = doc.CreateElement("FG_MIN");
                    fg_min.InnerText = txtMinFGStyles.Text;

                    XmlElement fg_max = doc.CreateElement("FG_MAX");
                    fg_max.InnerText = txtMaxFGStyles.Text;

                    XmlElement ibu_min = doc.CreateElement("IBU_MIN");
                    ibu_min.InnerText = txtMinIBUStyles.Text;

                    XmlElement ibu_max = doc.CreateElement("IBU_MAX");
                    ibu_max.InnerText = txtMaxIBUStyles.Text;

                    XmlElement color_min = doc.CreateElement("COLOR_MIN");
                    color_min.InnerText = txtMinColorStyles.Text;

                    XmlElement color_max = doc.CreateElement("COLOR_MAX");
                    color_max.InnerText = txtMaxColorStyles.Text;

                    XmlElement carb_min = doc.CreateElement("CARB_MIN");
                    carb_min.InnerText = txtMinCarbStyles.Text;

                    XmlElement carb_max = doc.CreateElement("CARB_MAX");
                    carb_max.InnerText = txtMaxCarbStyles.Text;

                    XmlElement abv_max = doc.CreateElement("ABV_MAX");
                    abv_max.InnerText = txtMaxABVStyles.Text;

                    XmlElement abv_min = doc.CreateElement("ABV_MIN");
                    abv_min.InnerText = txtMinABVStyles.Text;

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesStyles.Text;

                    XmlElement profile = doc.CreateElement("PROFILE");
                    profile.InnerText = txtProfileStyles.Text;

                    XmlElement ingredients = doc.CreateElement("INGREDIENTS");
                    ingredients.InnerText = txtIngredientsStyles.Text;

                    XmlElement examples = doc.CreateElement("EXAMPLES");
                    examples.InnerText = txtExamplesStyles.Text;

                    XmlElement display_og_min = doc.CreateElement("DISPLAY_OG_MIN");
                    display_og_min.InnerText = "1.035 SG";

                    XmlElement display_og_max = doc.CreateElement("DISPLAY_OG_MAX");
                    display_og_max.InnerText = "1.055 SG";

                    XmlElement display_fg_min = doc.CreateElement("DISPLAY_FG_MIN");
                    display_fg_min.InnerText = "1.008 SG";

                    XmlElement display_fg_max = doc.CreateElement("DISPLAY_FG_MAX");
                    display_fg_max.InnerText = "1.015 SG";

                    XmlElement display_color_min = doc.CreateElement("DISPLAY_COLOR_MIN");
                    display_color_min.InnerText = "2.0 SRM";

                    XmlElement display_color_max = doc.CreateElement("DISPLAY_COLOR_MAX");
                    display_color_max.InnerText = "8.0 SRM";

                    XmlElement og_range = doc.CreateElement("OG_RANGE");
                    og_range.InnerText = "1.035-1.055 SG";

                    XmlElement fg_range = doc.CreateElement("FG_RANGE");
                    fg_range.InnerText = "1.008-1.015 SG";

                    XmlElement ibu_range = doc.CreateElement("IBU_RANGE");
                    ibu_range.InnerText = "10.0-30.0 IBU";

                    XmlElement carb_range = doc.CreateElement("CARB_RANGE");
                    carb_range.InnerText = "2.3-2.6 vols";

                    XmlElement color_range = doc.CreateElement("COLOR_RANGE");
                    color_range.InnerText = "2.0-8.0 SRM";

                    XmlElement abv_range = doc.CreateElement("ABV_RANGE");
                    abv_range.InnerText = "3.7-5.5 %";

                    style.AppendChild(name);
                    style.AppendChild(version);
                    style.AppendChild(category);
                    style.AppendChild(category_number);
                    style.AppendChild(style_letter);
                    style.AppendChild(style_guide);
                    style.AppendChild(type);
                    style.AppendChild(og_min);
                    style.AppendChild(og_max);
                    style.AppendChild(fg_min);
                    style.AppendChild(fg_max);
                    style.AppendChild(ibu_min);
                    style.AppendChild(ibu_max);
                    style.AppendChild(color_min);
                    style.AppendChild(color_max);
                    style.AppendChild(carb_min);
                    style.AppendChild(carb_max);
                    style.AppendChild(abv_max);
                    style.AppendChild(abv_min);
                    style.AppendChild(notes);
                    style.AppendChild(profile);
                    style.AppendChild(ingredients);
                    style.AppendChild(examples);
                    style.AppendChild(display_og_min);
                    style.AppendChild(display_og_max);
                    style.AppendChild(display_fg_min);
                    style.AppendChild(display_fg_max);
                    style.AppendChild(display_color_min);
                    style.AppendChild(display_color_max);
                    style.AppendChild(og_range);
                    style.AppendChild(fg_range);
                    style.AppendChild(ibu_range);
                    style.AppendChild(carb_range);
                    style.AppendChild(color_range);
                    style.AppendChild(abv_range);

                    styles.AppendChild(style);
                    doc.AppendChild(styles);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  style";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportStyles_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Styles> styles = new List<Styles>();
                styles = ul.ListStyles(doc);
                for (int i = 0; i < styles.Count; i++)
                {
                    
                        XmlElement style = documentStyle.CreateElement("STYLE");

                        XmlElement name = documentStyle.CreateElement("NAME");
                        name.InnerText = styles[i].getNAME().ToString();

                        XmlElement version = documentStyle.CreateElement("VERSION");
                        version.InnerText = styles[i].getVERSION().ToString();

                        XmlElement category = documentStyle.CreateElement("CATEGORY");
                        category.InnerText = styles[i].getCATEGORY().ToString();

                        XmlElement category_number = documentStyle.CreateElement("CATEGORY_NUMBER");
                        category_number.InnerText = styles[i].getCATEGORY_NUMBER().ToString();

                        XmlElement style_letter = documentStyle.CreateElement("STYLE_LETTER");
                        style_letter.InnerText = styles[i].getSTYLE_LETTER().ToString();

                        XmlElement style_guide = documentStyle.CreateElement("STYLE_GUIDE");
                        style_guide.InnerText = styles[i].getSTYLE_GUIDE().ToString();

                        XmlElement type = documentStyle.CreateElement("TYPE");
                        type.InnerText = styles[i].getTYPE().ToString();

                        XmlElement og_min = documentStyle.CreateElement("OG_MIN");
                        og_min.InnerText = styles[i].getOG_MIN().ToString();

                        XmlElement og_max = documentStyle.CreateElement("OG_MAX");
                        og_max.InnerText = styles[i].getOG_MAX().ToString();

                        XmlElement fg_min = documentStyle.CreateElement("FG_MIN");
                        fg_min.InnerText = styles[i].getFG_MIN().ToString();

                        XmlElement fg_max = documentStyle.CreateElement("FG_MAX");
                        fg_max.InnerText = styles[i].getFG_MAX().ToString();

                        XmlElement ibu_min = documentStyle.CreateElement("IBU_MIN");
                        ibu_min.InnerText = styles[i].getIBU_MIN().ToString();

                        XmlElement ibu_max = documentStyle.CreateElement("IBU_MAX");
                        ibu_max.InnerText = styles[i].getIBU_MAX().ToString();

                        XmlElement color_min = documentStyle.CreateElement("COLOR_MIN");
                        color_min.InnerText = styles[i].getCOLOR_MIN().ToString();

                        XmlElement color_max = documentStyle.CreateElement("COLOR_MAX");
                        color_max.InnerText = styles[i].getCOLOR_MAX().ToString();

                        XmlElement carb_min = documentStyle.CreateElement("CARB_MIN");
                        carb_min.InnerText = styles[i].getCARB_MIN().ToString();

                        XmlElement carb_max = documentStyle.CreateElement("CARB_MAX");
                        carb_max.InnerText = styles[i].getCARB_MAX().ToString();

                        XmlElement abv_max = documentStyle.CreateElement("ABV_MAX");
                        abv_max.InnerText = styles[i].getABV_MAX().ToString();

                        XmlElement abv_min = documentStyle.CreateElement("ABV_MIN");
                        abv_min.InnerText = styles[i].getABV_MIN().ToString();

                        XmlElement notes = documentStyle.CreateElement("NOTES");
                        notes.InnerText = styles[i].getNOTES().ToString();

                        XmlElement profile = documentStyle.CreateElement("PROFILE");
                        profile.InnerText = styles[i].getPROFILE().ToString();

                        XmlElement ingredients = documentStyle.CreateElement("INGREDIENTS");
                        ingredients.InnerText = styles[i].getINGREDIENTS().ToString();

                        XmlElement examples = documentStyle.CreateElement("EXAMPLES");
                        examples.InnerText = styles[i].getEXAMPLES().ToString();

                        XmlElement display_og_min = documentStyle.CreateElement("DISPLAY_OG_MIN");
                        display_og_min.InnerText = styles[i].getDISPLAY_OG_MIN().ToString();

                        XmlElement display_og_max = documentStyle.CreateElement("DISPLAY_OG_MAX");
                        display_og_max.InnerText = styles[i].getDISPLAY_OG_MAX().ToString();

                        XmlElement display_fg_min = documentStyle.CreateElement("DISPLAY_FG_MIN");
                        display_fg_min.InnerText = styles[i].getDISPLAY_FG_MIN().ToString();

                        XmlElement display_fg_max = documentStyle.CreateElement("DISPLAY_FG_MAX");
                        display_fg_max.InnerText = styles[i].getDISPLAY_FG_MAX().ToString();

                        XmlElement display_color_min = documentStyle.CreateElement("DISPLAY_COLOR_MIN");
                        display_color_min.InnerText = styles[i].getDISPLAY_COLOR_MIN().ToString();

                        XmlElement display_color_max = documentStyle.CreateElement("DISPLAY_COLOR_MAX");
                        display_color_max.InnerText = styles[i].getDISPLAY_COLOR_MAX().ToString();

                        XmlElement og_range = documentStyle.CreateElement("OG_RANGE");
                        og_range.InnerText = styles[i].getOG_RANGE().ToString();

                        XmlElement fg_range = documentStyle.CreateElement("FG_RANGE");
                        fg_range.InnerText = styles[i].getFG_RANGE().ToString();

                        XmlElement ibu_range = documentStyle.CreateElement("IBU_RANGE");
                        ibu_range.InnerText = styles[i].getIBU_RANGE().ToString();

                        XmlElement carb_range = documentStyle.CreateElement("CARB_RANGE");
                        carb_range.InnerText = styles[i].getCARB_RANGE().ToString();

                        XmlElement color_range = documentStyle.CreateElement("COLOR_RANGE");
                        color_range.InnerText = styles[i].getCOLOR_RANGE().ToString();

                        XmlElement abv_range = documentStyle.CreateElement("ABV_RANGE");
                        abv_range.InnerText = styles[i].getABV_RANGE().ToString();

                        style.AppendChild(name);
                        style.AppendChild(version);
                        style.AppendChild(category);
                        style.AppendChild(category_number);
                        style.AppendChild(style_letter);
                        style.AppendChild(style_guide);
                        style.AppendChild(type);
                        style.AppendChild(og_min);
                        style.AppendChild(og_max);
                        style.AppendChild(fg_min);
                        style.AppendChild(fg_max);
                        style.AppendChild(ibu_min);
                        style.AppendChild(ibu_max);
                        style.AppendChild(color_min);
                        style.AppendChild(color_max);
                        style.AppendChild(carb_min);
                        style.AppendChild(carb_max);
                        style.AppendChild(abv_max);
                        style.AppendChild(abv_min);
                        style.AppendChild(notes);
                        style.AppendChild(profile);
                        style.AppendChild(ingredients);
                        style.AppendChild(examples);
                        style.AppendChild(display_og_min);
                        style.AppendChild(display_og_max);
                        style.AppendChild(display_fg_min);
                        style.AppendChild(display_fg_max);
                        style.AppendChild(display_color_min);
                        style.AppendChild(display_color_max);
                        style.AppendChild(og_range);
                        style.AppendChild(fg_range);
                        style.AppendChild(ibu_range);
                        style.AppendChild(carb_range);
                        style.AppendChild(color_range);
                        style.AppendChild(abv_range);

                        documentStyle.DocumentElement.InsertAfter(style, documentStyle.DocumentElement.LastChild);
                        try
                        {
                            fsStyle = new FileStream(fileStyle, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                        }
                        catch (Exception) { }
                        documentStyle.Save(fsStyle);
                    
                }
                loadStyles();
                message.title = "Import";
                message.Content = "Import style success.";
                message.ShowDialog();
                fsPath.Close();
            }
        }

        private void tableStyles_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameStyles.Text = tableViewStyles.GetFocusedDataRow()["name"].ToString();
                txtCategoryStyles.Text = tableViewStyles.GetFocusedDataRow()["category"].ToString();
                txtCategoryNumberStyles.Text = tableViewStyles.GetFocusedDataRow()["category_number"].ToString();
                txtStyleLetterStyles.Text = tableViewStyles.GetFocusedDataRow()["style_letter"].ToString();
                txtStyleGuideStyles.Text = tableViewStyles.GetFocusedDataRow()["style_guide"].ToString();
                cbbTypeStyles.Text = tableViewStyles.GetFocusedDataRow()["type"].ToString();
                txtMinOGStyles.Text = tableViewStyles.GetFocusedDataRow()["og_min"].ToString();
                txtMaxOGStyles.Text = tableViewStyles.GetFocusedDataRow()["og_max"].ToString();
                txtMinFGStyles.Text = tableViewStyles.GetFocusedDataRow()["fg_min"].ToString();
                txtMaxFGStyles.Text = tableViewStyles.GetFocusedDataRow()["fg_max"].ToString();
                txtMinIBUStyles.Text = tableViewStyles.GetFocusedDataRow()["ibu_min"].ToString();
                txtMaxIBUStyles.Text = tableViewStyles.GetFocusedDataRow()["ibu_max"].ToString();
                txtMinColorStyles.Text = tableViewStyles.GetFocusedDataRow()["color_min"].ToString();
                txtMaxColorStyles.Text = tableViewStyles.GetFocusedDataRow()["color_max"].ToString();
                txtMinCarbStyles.Text = tableViewStyles.GetFocusedDataRow()["carb_min"].ToString();
                txtMaxCarbStyles.Text = tableViewStyles.GetFocusedDataRow()["carb_max"].ToString();
                txtMinABVStyles.Text = tableViewStyles.GetFocusedDataRow()["abv_min"].ToString();
                txtMaxABVStyles.Text = tableViewStyles.GetFocusedDataRow()["abv_max"].ToString();
                txtProfileStyles.Text = tableViewStyles.GetFocusedDataRow()["profile"].ToString();
                txtIngredientsStyles.Text = tableViewStyles.GetFocusedDataRow()["ingredients"].ToString();
                txtExamplesStyles.Text = tableViewStyles.GetFocusedDataRow()["examples"].ToString();
                txtNotesStyles.Text = tableViewStyles.GetFocusedDataRow()["notes"].ToString();

            }
            catch (Exception) { }
        }

        //Recipes
        private void btnNewRecipes_Click(object sender, EventArgs e)
        {
            txtRecipes.Text = "";
            cbbStyleRecipes.Text = "";
            cbbEquipmentRecipes.Text = "";
            txtTargetBatchSizeRecipes.Text = "18.930 L";
            txtCaculatedBatchSizeRecipes.Text = "0.000 mL";
            txtTargetBoilSizeRecipes.Text = "23.470 L";
            txtEfficiencyRecipes.Text = "70";
            txtBoilTimeRecipes.Text = "0.000 s";
            lbOGRecipes.Text = "1.080";
            lbBoilSGRecipes.Text = "1.000";
            lbFGRecipes.Text = "1.016";
            lbABVRecipes.Text = "8.0";
            lbBitternessRecipes.Text = "50.0";
            lbColorRecipes.Text = "10.0";
            lbIBURecipes.Text = "0.00";
            txtBrewerRecipes.Text = "";
            txtAsstBrewerRecipes.Text = "";
            txtTasteRatingRecipes.Text = "0";
            txtPrimaryAgeRecipes.Text = "0.000 s";
            txtPrimaryTempRecipes.Text = "20.000 C";
            txtSecondaryAgeRecipes.Text = "0.000 s";
            txtSecondaryTempRecipes.Text = "20.000 C";
            txtTertiaryAgeRecipes.Text = "0.000 s";
            txtTertiaryTempRecipes.Text = "20.000 C";
            txtBottleKeyAgeRecipes.Text = "0.000 s";
            txtBottleKeyTempRecipes.Text = "20.000 C";
            cbbdateDateFirstBrewedRecipes.Text = "";
            txtCarbonationVolumesRecipes.Text = "0.000";
            txtTasteNotesRecipes.Text = "";
            txtNotesRecipes.Text = "";
            
            // Fermentable
            DataTable dtFermentable = new DataTable();
            tableFermentablesRecipes.DataSource = dtFermentable;
            dtFermentable.Columns.Add("name", typeof(string));
            dtFermentable.Columns.Add("type", typeof(string));
            dtFermentable.Columns.Add("amount", typeof(string));
            dtFermentable.Columns.Add("yield", typeof(string));
            dtFermentable.Columns.Add("color", typeof(string));
            dtFermentable.Columns.Add("display_amount", typeof(string));

            //Hops
            DataTable dtHop = new DataTable();
            tableHopsRecipes.DataSource = dtHop;
            dtHop.Columns.Add("name", typeof(string));
            dtHop.Columns.Add("alpha", typeof(string));
            dtHop.Columns.Add("amount", typeof(string));
            dtHop.Columns.Add("form", typeof(string));
            dtHop.Columns.Add("use", typeof(string));
            dtHop.Columns.Add("time", typeof(string));

            //Miscs
            DataTable dtMisc = new DataTable();
            tableMiscsRecipes.DataSource = dtMisc;
            dtMisc.Columns.Add("name", typeof(string));
            dtMisc.Columns.Add("type", typeof(string));
            dtMisc.Columns.Add("use", typeof(string));
            dtMisc.Columns.Add("time", typeof(string));
            dtMisc.Columns.Add("amount", typeof(string));
            dtMisc.Columns.Add("form", typeof(string));

            //Yeast
            DataTable dtYeast = new DataTable();
            tableYeastsRecipes.DataSource = dtYeast;
            dtYeast.Columns.Add("name", typeof(string));
            dtYeast.Columns.Add("type", typeof(string));
            dtYeast.Columns.Add("form", typeof(string));
            dtYeast.Columns.Add("amount", typeof(string));

            //Mash
            DataTable dtMash = new DataTable();
            tableMashRecipes.DataSource = dtMash;
            dtMash.Columns.Add("name", typeof(string));
            dtMash.Columns.Add("type", typeof(string));
            dtMash.Columns.Add("infuse_amount", typeof(string));
            dtMash.Columns.Add("infuse_temp", typeof(string));
            dtMash.Columns.Add("step_time", typeof(string));
        }

        private void btnSaveRecipes_Click(object sender, EventArgs e)
        {
            if (txtRecipes.Text == "")
            {
                message.title = "Error";
                message.Content = "Recipe name not null";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentRecipe.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::RECIPE[NAME='" + txtRecipes.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = "All Grain";
                    node.ChildNodes[3].InnerText = txtBrewerRecipes.Text;
                    node.ChildNodes[4].InnerText = txtAsstBrewerRecipes.Text;
                    node.ChildNodes[5].InnerText = txtTargetBatchSizeRecipes.Text;
                    node.ChildNodes[6].InnerText = txtTargetBoilSizeRecipes.Text;
                    node.ChildNodes[7].InnerText = txtBoilTimeRecipes.Text;
                    node.ChildNodes[8].InnerText = txtEfficiencyRecipes.Text;
                    //Hops
                    node.ChildNodes[9].RemoveAll();
                    if (tableViewHopsRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewHopsRecipes.DataRowCount; i++)
                        {
                            XmlElement hop = documentRecipe.CreateElement("HOP");

                            XmlElement hop_name = documentRecipe.CreateElement("NAME");
                            hop_name.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement hop_version = documentRecipe.CreateElement("VERSION");
                            hop_version.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "version").ToString();

                            XmlElement hop_origin = documentRecipe.CreateElement("ORIGIN");
                            hop_origin.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "origin").ToString();

                            XmlElement hop_alpha = documentRecipe.CreateElement("ALPHA");
                            hop_alpha.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "alpha").ToString();

                            XmlElement hop_amount = documentRecipe.CreateElement("AMOUNT");
                            hop_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "amount").ToString().Replace("mg","");

                            XmlElement hop_use = documentRecipe.CreateElement("USE");
                            hop_use.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "use").ToString();

                            XmlElement hop_time = documentRecipe.CreateElement("TIME");
                            hop_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "time").ToString().Replace("s","");

                            XmlElement hop_notes = documentRecipe.CreateElement("NOTES");
                            hop_notes.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement hop_type = documentRecipe.CreateElement("TYPE");
                            hop_type.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement hop_form = documentRecipe.CreateElement("FORM");
                            hop_form.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "form").ToString();

                            XmlElement hop_beta = documentRecipe.CreateElement("BETA");
                            hop_beta.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "beta").ToString();

                            XmlElement hop_hsi = documentRecipe.CreateElement("HSI");
                            hop_hsi.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "hsi").ToString();

                            XmlElement hop_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            hop_display_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement hop_inventory = documentRecipe.CreateElement("INVENTORY");
                            hop_inventory.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement hop_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                            hop_display_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_time").ToString();

                            hop.AppendChild(hop_name);
                            hop.AppendChild(hop_version);
                            hop.AppendChild(hop_origin);
                            hop.AppendChild(hop_alpha);
                            hop.AppendChild(hop_amount);
                            hop.AppendChild(hop_use);
                            hop.AppendChild(hop_time);
                            hop.AppendChild(hop_notes);
                            hop.AppendChild(hop_type);
                            hop.AppendChild(hop_form);
                            hop.AppendChild(hop_beta);
                            hop.AppendChild(hop_hsi);
                            hop.AppendChild(hop_display_amount);
                            hop.AppendChild(hop_inventory);
                            hop.AppendChild(hop_display_time);

                            node.ChildNodes[9].AppendChild(hop);
                        }
                    }
                    else
                    {
                        XmlElement hop = documentRecipe.CreateElement("HOP");

                        XmlElement hop_name = documentRecipe.CreateElement("NAME");
                        hop_name.InnerText = "Fuggles";

                        XmlElement hop_version = documentRecipe.CreateElement("VERSION");
                        hop_version.InnerText = "1";

                        XmlElement hop_origin = documentRecipe.CreateElement("ORIGIN");
                        hop_origin.InnerText = "Germany";

                        XmlElement hop_alpha = documentRecipe.CreateElement("ALPHA");
                        hop_alpha.InnerText = "7.5";

                        XmlElement hop_amount = documentRecipe.CreateElement("AMOUNT");
                        hop_amount.InnerText = "0.014175";

                        XmlElement hop_use = documentRecipe.CreateElement("USE");
                        hop_use.InnerText = "Boil";

                        XmlElement hop_time = documentRecipe.CreateElement("TIME");
                        hop_time.InnerText = "60";

                        XmlElement hop_notes = documentRecipe.CreateElement("NOTES");
                        hop_notes.InnerText = "";

                        XmlElement hop_type = documentRecipe.CreateElement("TYPE");
                        hop_type.InnerText = "Both";

                        XmlElement hop_form = documentRecipe.CreateElement("FORM");
                        hop_form.InnerText = "Pellet";

                        XmlElement hop_beta = documentRecipe.CreateElement("BETA");
                        hop_beta.InnerText = "4";

                        XmlElement hop_hsi = documentRecipe.CreateElement("HSI");
                        hop_hsi.InnerText = "35";

                        XmlElement hop_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        hop_display_amount.InnerText = "0.00 oz";

                        XmlElement hop_inventory = documentRecipe.CreateElement("INVENTORY");
                        hop_inventory.InnerText = "0.00 oz";

                        XmlElement hop_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        hop_display_time.InnerText = "-";

                        hop.AppendChild(hop_name);
                        hop.AppendChild(hop_version);
                        hop.AppendChild(hop_origin);
                        hop.AppendChild(hop_alpha);
                        hop.AppendChild(hop_amount);
                        hop.AppendChild(hop_use);
                        hop.AppendChild(hop_time);
                        hop.AppendChild(hop_notes);
                        hop.AppendChild(hop_type);
                        hop.AppendChild(hop_form);
                        hop.AppendChild(hop_beta);
                        hop.AppendChild(hop_hsi);
                        hop.AppendChild(hop_display_amount);
                        hop.AppendChild(hop_inventory);
                        hop.AppendChild(hop_display_time);

                        node.ChildNodes[9].AppendChild(hop);
                    }

                    //Fermentables
                    node.ChildNodes[10].RemoveAll();
                    if (tableViewFermentablesRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
                        {
                            XmlElement fermentable = documentRecipe.CreateElement("FERMENTABLE");

                            XmlElement fermentable_name = documentRecipe.CreateElement("NAME");
                            fermentable_name.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement fermentable_version = documentRecipe.CreateElement("VERSION");
                            fermentable_version.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "version").ToString();

                            XmlElement fermentable_type = documentRecipe.CreateElement("TYPE");
                            fermentable_type.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement fermentable_amount = documentRecipe.CreateElement("AMOUNT");
                            fermentable_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement fermentable_yield = documentRecipe.CreateElement("YIELD");
                            fermentable_yield.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "yield").ToString();

                            XmlElement fermentable_color = documentRecipe.CreateElement("COLOR");
                            fermentable_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString();

                            XmlElement fermentable_add_after_boil = documentRecipe.CreateElement("ADD_AFTER_BOIL");
                            fermentable_add_after_boil.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "add_after_boil").ToString();

                            XmlElement fermentable_origin = documentRecipe.CreateElement("ORIGIN");
                            fermentable_origin.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "origin").ToString();

                            XmlElement fermentable_supplier = documentRecipe.CreateElement("SUPPLIER");
                            fermentable_supplier.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "supplier").ToString();

                            XmlElement fermentable_notes = documentRecipe.CreateElement("NOTES");
                            fermentable_notes.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement fermentable_coarse_fine_diff = documentRecipe.CreateElement("COARSE_FINE_DIFF");
                            fermentable_coarse_fine_diff.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "coarse_fine_diff").ToString();

                            XmlElement fermentable_moisture = documentRecipe.CreateElement("MOISTURE");
                            fermentable_moisture.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "moisture").ToString();

                            XmlElement fermentable_diastatic_power = documentRecipe.CreateElement("DIASTATIC_POWER");
                            fermentable_diastatic_power.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "diastatic_power").ToString();

                            XmlElement fermentable_protein = documentRecipe.CreateElement("PROTEIN");
                            fermentable_protein.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "protein").ToString();

                            XmlElement fermentable_max_in_batch = documentRecipe.CreateElement("MAX_IN_BATCH");
                            fermentable_max_in_batch.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "max_in_batch").ToString();

                            XmlElement fermentable_recommend_mash = documentRecipe.CreateElement("RECOMMEND_MASH");
                            fermentable_recommend_mash.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "recommend_mash").ToString();

                            XmlElement fermentable_ibu_gal_per_lb = documentRecipe.CreateElement("IBU_GAL_PER_LB");
                            fermentable_ibu_gal_per_lb.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "ibu_gal_per_lb").ToString();

                            XmlElement fermentable_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            fermentable_display_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement fermentable_inventory = documentRecipe.CreateElement("INVENTORY");
                            fermentable_inventory.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement fermentable_potential = documentRecipe.CreateElement("POTENTIAL");
                            fermentable_potential.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "potential").ToString();

                            XmlElement fermentable_display_color = documentRecipe.CreateElement("DISPLAY_COLOR");
                            fermentable_display_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_color").ToString();


                            fermentable.AppendChild(fermentable_name);
                            fermentable.AppendChild(fermentable_version);
                            fermentable.AppendChild(fermentable_type);
                            fermentable.AppendChild(fermentable_amount);
                            fermentable.AppendChild(fermentable_yield);
                            fermentable.AppendChild(fermentable_color);
                            fermentable.AppendChild(fermentable_add_after_boil);
                            fermentable.AppendChild(fermentable_origin);
                            fermentable.AppendChild(fermentable_supplier);
                            fermentable.AppendChild(fermentable_notes);
                            fermentable.AppendChild(fermentable_coarse_fine_diff);
                            fermentable.AppendChild(fermentable_moisture);
                            fermentable.AppendChild(fermentable_diastatic_power);
                            fermentable.AppendChild(fermentable_protein);
                            fermentable.AppendChild(fermentable_max_in_batch);
                            fermentable.AppendChild(fermentable_recommend_mash);
                            fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                            fermentable.AppendChild(fermentable_display_amount);
                            fermentable.AppendChild(fermentable_inventory);
                            fermentable.AppendChild(fermentable_potential);
                            fermentable.AppendChild(fermentable_display_color);

                            node.ChildNodes[10].AppendChild(fermentable);
                        }
                    }
                    else
                    {
                        XmlElement fermentable = documentRecipe.CreateElement("FERMENTABLE");

                        XmlElement fermentable_name = documentRecipe.CreateElement("NAME");
                        fermentable_name.InnerText = "Caramel/Crystal Malt - 20L";

                        XmlElement fermentable_version = documentRecipe.CreateElement("VERSION");
                        fermentable_version.InnerText = "1";

                        XmlElement fermentable_type = documentRecipe.CreateElement("TYPE");
                        fermentable_type.InnerText = "Grain";

                        XmlElement fermentable_amount = documentRecipe.CreateElement("AMOUNT");
                        fermentable_amount.InnerText = "0.453592";

                        XmlElement fermentable_yield = documentRecipe.CreateElement("YIELD");
                        fermentable_yield.InnerText = "75";

                        XmlElement fermentable_color = documentRecipe.CreateElement("COLOR");
                        fermentable_color.InnerText = "20";

                        XmlElement fermentable_add_after_boil = documentRecipe.CreateElement("ADD_AFTER_BOIL");
                        fermentable_add_after_boil.InnerText = "FALSE";

                        XmlElement fermentable_origin = documentRecipe.CreateElement("ORIGIN");
                        fermentable_origin.InnerText = "US";

                        XmlElement fermentable_supplier = documentRecipe.CreateElement("SUPPLIER");
                        fermentable_supplier.InnerText = "";

                        XmlElement fermentable_notes = documentRecipe.CreateElement("NOTES");
                        fermentable_notes.InnerText = "";

                        XmlElement fermentable_coarse_fine_diff = documentRecipe.CreateElement("COARSE_FINE_DIFF");
                        fermentable_coarse_fine_diff.InnerText = "1.5";

                        XmlElement fermentable_moisture = documentRecipe.CreateElement("MOISTURE");
                        fermentable_moisture.InnerText = "4";

                        XmlElement fermentable_diastatic_power = documentRecipe.CreateElement("DIASTATIC_POWER");
                        fermentable_diastatic_power.InnerText = "0";

                        XmlElement fermentable_protein = documentRecipe.CreateElement("PROTEIN");
                        fermentable_protein.InnerText = "13.2";

                        XmlElement fermentable_max_in_batch = documentRecipe.CreateElement("MAX_IN_BATCH");
                        fermentable_max_in_batch.InnerText = "20";

                        XmlElement fermentable_recommend_mash = documentRecipe.CreateElement("RECOMMEND_MASH");
                        fermentable_recommend_mash.InnerText = "FALSE";

                        XmlElement fermentable_ibu_gal_per_lb = documentRecipe.CreateElement("IBU_GAL_PER_LB");
                        fermentable_ibu_gal_per_lb.InnerText = "0";

                        XmlElement fermentable_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        fermentable_display_amount.InnerText = "0.00 lb";

                        XmlElement fermentable_inventory = documentRecipe.CreateElement("INVENTORY");
                        fermentable_inventory.InnerText = "0.00 lb";

                        XmlElement fermentable_potential = documentRecipe.CreateElement("POTENTIAL");
                        fermentable_potential.InnerText = "0.000";

                        XmlElement fermentable_display_color = documentRecipe.CreateElement("DISPLAY_COLOR");
                        fermentable_display_color.InnerText = "";


                        fermentable.AppendChild(fermentable_name);
                        fermentable.AppendChild(fermentable_version);
                        fermentable.AppendChild(fermentable_type);
                        fermentable.AppendChild(fermentable_amount);
                        fermentable.AppendChild(fermentable_yield);
                        fermentable.AppendChild(fermentable_color);
                        fermentable.AppendChild(fermentable_add_after_boil);
                        fermentable.AppendChild(fermentable_origin);
                        fermentable.AppendChild(fermentable_supplier);
                        fermentable.AppendChild(fermentable_notes);
                        fermentable.AppendChild(fermentable_coarse_fine_diff);
                        fermentable.AppendChild(fermentable_moisture);
                        fermentable.AppendChild(fermentable_diastatic_power);
                        fermentable.AppendChild(fermentable_protein);
                        fermentable.AppendChild(fermentable_max_in_batch);
                        fermentable.AppendChild(fermentable_recommend_mash);
                        fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                        fermentable.AppendChild(fermentable_display_amount);
                        fermentable.AppendChild(fermentable_inventory);
                        fermentable.AppendChild(fermentable_potential);
                        fermentable.AppendChild(fermentable_display_color);

                        node.ChildNodes[10].AppendChild(fermentable);
                    }

                    //Miscs
                    node.ChildNodes[11].RemoveAll();
                    if (tableViewMiscRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewMiscRecipes.DataRowCount; i++)
                        {
                            XmlElement misc = documentRecipe.CreateElement("MISC");

                            XmlElement misc_name = documentRecipe.CreateElement("NAME");
                            misc_name.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                            misc_version.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "version").ToString();

                            XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                            misc_type.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement misc_use = documentRecipe.CreateElement("USE");
                            misc_use.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use").ToString();

                            XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                            misc_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount").ToString().Replace("mg","");

                            XmlElement misc_time = documentRecipe.CreateElement("TIME");
                            misc_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "time").ToString().Replace("s","");

                            XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                            misc_amount_is_weight.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                            XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                            misc_use_for.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use_for").ToString();

                            XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                            misc_notes.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            misc_display_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                            misc_inventory.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                            misc_display_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_time").ToString();

                            misc.AppendChild(misc_name);
                            misc.AppendChild(misc_version);
                            misc.AppendChild(misc_type);
                            misc.AppendChild(misc_use);
                            misc.AppendChild(misc_amount);
                            misc.AppendChild(misc_time);
                            misc.AppendChild(misc_amount_is_weight);
                            misc.AppendChild(misc_notes);
                            misc.AppendChild(misc_display_amount);
                            misc.AppendChild(misc_inventory);
                            misc.AppendChild(misc_display_time);
                            node.ChildNodes[11].AppendChild(misc);
                        }
                    }
                    else
                    {
                        XmlElement misc = documentRecipe.CreateElement("MISC");

                        XmlElement misc_name = documentRecipe.CreateElement("NAME");
                        misc_name.InnerText = "Orange Peel, Bitter";

                        XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                        misc_version.InnerText = "1";

                        XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                        misc_type.InnerText = "Spice";

                        XmlElement misc_use = documentRecipe.CreateElement("USE");
                        misc_use.InnerText = "Boil";

                        XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                        misc_amount.InnerText = "0.02218";

                        XmlElement misc_time = documentRecipe.CreateElement("TIME");
                        misc_time.InnerText = "60";

                        XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        misc_amount_is_weight.InnerText = "FALSE";

                        XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                        misc_use_for.InnerText = "Fruit Beer";

                        XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                        misc_notes.InnerText = "";

                        XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        misc_display_amount.InnerText = "6.50 oz";

                        XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                        misc_inventory.InnerText = "0.00 oz";

                        XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        misc_display_time.InnerText = "5.0 min";

                        misc.AppendChild(misc_name);
                        misc.AppendChild(misc_version);
                        misc.AppendChild(misc_type);
                        misc.AppendChild(misc_use);
                        misc.AppendChild(misc_amount);
                        misc.AppendChild(misc_time);
                        misc.AppendChild(misc_amount_is_weight);
                        misc.AppendChild(misc_notes);
                        misc.AppendChild(misc_display_amount);
                        misc.AppendChild(misc_inventory);
                        misc.AppendChild(misc_display_time);
                        node.ChildNodes[11].AppendChild(misc);
                    }
                    //Yeasts
                    node.ChildNodes[12].RemoveAll();
                    if (tableViewYeastRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewYeastRecipes.DataRowCount; i++)
                        {
                            XmlElement yeast = documentRecipe.CreateElement("YEAST");

                            XmlElement yeast_name = documentRecipe.CreateElement("NAME");
                            yeast_name.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement yeast_version = documentRecipe.CreateElement("VERSION");
                            yeast_version.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "version").ToString();

                            XmlElement yeast_type = documentRecipe.CreateElement("TYPE");
                            yeast_type.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement yeast_form = documentRecipe.CreateElement("FORM");
                            yeast_form.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "form").ToString();

                            XmlElement yeast_amount = documentRecipe.CreateElement("AMOUNT");
                            yeast_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement yeast_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                            yeast_amount_is_weight.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                            XmlElement yeast_laboratory = documentRecipe.CreateElement("LABORATORY");
                            yeast_laboratory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "laboratory").ToString();

                            XmlElement yeast_product_id = documentRecipe.CreateElement("PRODUCT_ID");
                            yeast_product_id.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "product_id").ToString();

                            XmlElement yeast_min_temperature = documentRecipe.CreateElement("MIN_TEMPERATURE");
                            yeast_min_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "min_temperature").ToString();

                            XmlElement yeast_max_temperature = documentRecipe.CreateElement("MAX_TEMPERATURE");
                            yeast_max_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_temperature").ToString();

                            XmlElement yeast_flocculation = documentRecipe.CreateElement("FLOCCULATION");
                            yeast_flocculation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "flocculation").ToString();

                            XmlElement yeast_attenuation = documentRecipe.CreateElement("ATTENUATION");
                            yeast_attenuation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "attenuation").ToString();

                            XmlElement yeast_notes = documentRecipe.CreateElement("NOTES");
                            yeast_notes.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement yeast_best_for = documentRecipe.CreateElement("BEST_FOR");
                            yeast_best_for.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "best_for").ToString();

                            XmlElement yeast_max_reuse = documentRecipe.CreateElement("MAX_REUSE");
                            yeast_max_reuse.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_reuse").ToString();

                            XmlElement yeast_times_cultured = documentRecipe.CreateElement("TIMES_CULTURED");
                            yeast_times_cultured.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "times_cultured").ToString();

                            XmlElement yeast_add_to_secondary = documentRecipe.CreateElement("ADD_TO_SECONDARY");
                            yeast_add_to_secondary.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "add_to_secondary").ToString();

                            XmlElement yeast_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            yeast_display_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement yeast_disp_min_temp = documentRecipe.CreateElement("DISP_MIN_TEMP");
                            yeast_disp_min_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_min_temp").ToString();

                            XmlElement yeast_disp_max_temp = documentRecipe.CreateElement("DISP_MAX_TEMP");
                            yeast_disp_max_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_max_temp").ToString();

                            XmlElement yeast_inventory = documentRecipe.CreateElement("INVENTORY");
                            yeast_inventory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement yeast_culture_date = documentRecipe.CreateElement("CULTURE_DATE");
                            yeast_culture_date.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "culture_date").ToString();


                            yeast.AppendChild(yeast_name);
                            yeast.AppendChild(yeast_version);
                            yeast.AppendChild(yeast_type);
                            yeast.AppendChild(yeast_form);
                            yeast.AppendChild(yeast_amount);
                            yeast.AppendChild(yeast_amount_is_weight);
                            yeast.AppendChild(yeast_laboratory);
                            yeast.AppendChild(yeast_product_id);
                            yeast.AppendChild(yeast_min_temperature);
                            yeast.AppendChild(yeast_max_temperature);
                            yeast.AppendChild(yeast_flocculation);
                            yeast.AppendChild(yeast_attenuation);
                            yeast.AppendChild(yeast_notes);
                            yeast.AppendChild(yeast_best_for);
                            yeast.AppendChild(yeast_max_reuse);
                            yeast.AppendChild(yeast_times_cultured);
                            yeast.AppendChild(yeast_add_to_secondary);
                            yeast.AppendChild(yeast_display_amount);
                            yeast.AppendChild(yeast_disp_min_temp);
                            yeast.AppendChild(yeast_disp_max_temp);
                            yeast.AppendChild(yeast_inventory);
                            yeast.AppendChild(yeast_culture_date);

                            node.ChildNodes[12].AppendChild(yeast);
                        }
                    }
                    else
                    {
                        XmlElement yeast = documentRecipe.CreateElement("YEAST");

                        XmlElement yeast_name = documentRecipe.CreateElement("NAME");
                        yeast_name.InnerText = "Northwest Ale";

                        XmlElement yeast_version = documentRecipe.CreateElement("VERSION");
                        yeast_version.InnerText = "1";

                        XmlElement yeast_type = documentRecipe.CreateElement("TYPE");
                        yeast_type.InnerText = "Ale";

                        XmlElement yeast_form = documentRecipe.CreateElement("FORM");
                        yeast_form.InnerText = "Liquid";

                        XmlElement yeast_amount = documentRecipe.CreateElement("AMOUNT");
                        yeast_amount.InnerText = "0";

                        XmlElement yeast_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        yeast_amount_is_weight.InnerText = "FALSE";

                        XmlElement yeast_laboratory = documentRecipe.CreateElement("LABORATORY");
                        yeast_laboratory.InnerText = "Wyeast Labs";

                        XmlElement yeast_product_id = documentRecipe.CreateElement("PRODUCT_ID");
                        yeast_product_id.InnerText = "1222";

                        XmlElement yeast_min_temperature = documentRecipe.CreateElement("MIN_TEMPERATURE");
                        yeast_min_temperature.InnerText = "0";

                        XmlElement yeast_max_temperature = documentRecipe.CreateElement("MAX_TEMPERATURE");
                        yeast_max_temperature.InnerText = "0";

                        XmlElement yeast_flocculation = documentRecipe.CreateElement("FLOCCULATION");
                        yeast_flocculation.InnerText = "High";

                        XmlElement yeast_attenuation = documentRecipe.CreateElement("ATTENUATION");
                        yeast_attenuation.InnerText = "69";

                        XmlElement yeast_notes = documentRecipe.CreateElement("NOTES");
                        yeast_notes.InnerText = "";

                        XmlElement yeast_best_for = documentRecipe.CreateElement("BEST_FOR");
                        yeast_best_for.InnerText = "";

                        XmlElement yeast_max_reuse = documentRecipe.CreateElement("MAX_REUSE");
                        yeast_max_reuse.InnerText = "5";

                        XmlElement yeast_times_cultured = documentRecipe.CreateElement("TIMES_CULTURED");
                        yeast_times_cultured.InnerText = "0";

                        XmlElement yeast_add_to_secondary = documentRecipe.CreateElement("ADD_TO_SECONDARY");
                        yeast_add_to_secondary.InnerText = "FALSE";

                        XmlElement yeast_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        yeast_display_amount.InnerText = "35 ml";

                        XmlElement yeast_disp_min_temp = documentRecipe.CreateElement("DISP_MIN_TEMP");
                        yeast_disp_min_temp.InnerText = "64.9 F";

                        XmlElement yeast_disp_max_temp = documentRecipe.CreateElement("DISP_MAX_TEMP");
                        yeast_disp_max_temp.InnerText = "68.0 F";

                        XmlElement yeast_inventory = documentRecipe.CreateElement("INVENTORY");
                        yeast_inventory.InnerText = "0 Pkgs";

                        XmlElement yeast_culture_date = documentRecipe.CreateElement("CULTURE_DATE");
                        yeast_culture_date.InnerText = "8/31/2014";


                        yeast.AppendChild(yeast_name);
                        yeast.AppendChild(yeast_version);
                        yeast.AppendChild(yeast_type);
                        yeast.AppendChild(yeast_form);
                        yeast.AppendChild(yeast_amount);
                        yeast.AppendChild(yeast_amount_is_weight);
                        yeast.AppendChild(yeast_laboratory);
                        yeast.AppendChild(yeast_product_id);
                        yeast.AppendChild(yeast_min_temperature);
                        yeast.AppendChild(yeast_max_temperature);
                        yeast.AppendChild(yeast_flocculation);
                        yeast.AppendChild(yeast_attenuation);
                        yeast.AppendChild(yeast_notes);
                        yeast.AppendChild(yeast_best_for);
                        yeast.AppendChild(yeast_max_reuse);
                        yeast.AppendChild(yeast_times_cultured);
                        yeast.AppendChild(yeast_add_to_secondary);
                        yeast.AppendChild(yeast_display_amount);
                        yeast.AppendChild(yeast_disp_min_temp);
                        yeast.AppendChild(yeast_disp_max_temp);
                        yeast.AppendChild(yeast_inventory);
                        yeast.AppendChild(yeast_culture_date);

                        node.ChildNodes[12].AppendChild(yeast);
                    }
                    //Water
                    //node.ChildNodes[13].InnerText = "water";
                    //Style
                    //node.ChildNodes[14].InnerText = "style";
                    if (cbbStyleRecipes.Text == "")
                    {
                        message.title = "Error";
                        message.Content = "Please choose style";
                        message.ShowDialog();
                        return;
                    }
                    node.ChildNodes[14].RemoveAll();
                    XmlNode style_root = documentStyle.DocumentElement;
                    XmlNode style_node = style_root.SelectSingleNode("descendant::STYLE[NAME='" + cbbStyleRecipes.Text + "']");
                    string style_name_text = "";
                    string style_version_text = "1";
                    string style_category_text = "";
                    string style_category_number_text = "1";
                    string style_style_letter_text = "";
                    string style_style_guide_text = "";
                    string style_type_text = "";
                    string style_og_min_text = "0.000";
                    string style_og_max_text = "0.000";
                    string style_fg_min_text = "0.000";
                    string style_fg_max_text = "0.000";
                    string style_ibu_min_text = "0.000";
                    string style_ibu_max_text = "0.000";
                    string style_color_min_text = "0.000";
                    string style_color_max_text = "0.000";
                    string style_carb_min_text = "0.000";
                    string style_carb_max_text = "0.000";
                    string style_abv_max_text = "0.000";
                    string style_abv_min_text = "0.000";
                    string style_notes_text = "";
                    string style_profile_text = "";
                    string style_ingredients_text = "";
                    string style_examples_text = "";
                    string style_display_og_min_text = "";
                    string style_display_og_max_text = "";
                    string style_display_fg_min_text = "";
                    string style_display_fg_max_text = "";
                    string style_display_color_min_text = "";
                    string style_display_color_max_text = "";
                    string style_og_range_text = "";
                    string style_fg_range_text = "";
                    string style_ibu_range_text = "";
                    string style_carb_range_text = "";
                    string style_color_range_text = "";
                    string style_abv_range_text = "";
                    if (style_node != null)
                    {
                        foreach (XmlNode nodes in style_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        style_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        style_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY":
                                    {
                                        style_category_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY_NUMBER":
                                    {
                                        style_category_number_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_LETTER":
                                    {
                                        style_style_letter_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_GUIDE":
                                    {
                                        style_style_guide_text = nodes.InnerText;
                                        break;
                                    }
                                case "TYPE":
                                    {
                                        style_type_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MIN":
                                    {
                                        style_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MAX":
                                    {
                                        style_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MIN":
                                    {
                                        style_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MAX":
                                    {
                                        style_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MIN":
                                    {
                                        style_ibu_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MAX":
                                    {
                                        style_ibu_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MIN":
                                    {
                                        style_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MAX":
                                    {
                                        style_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MIN":
                                    {
                                        style_carb_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MAX":
                                    {
                                        style_carb_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MAX":
                                    {
                                        style_abv_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MIN":
                                    {
                                        style_abv_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        style_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "PROFILE":
                                    {
                                        style_profile_text = nodes.InnerText;
                                        break;
                                    }
                                case "INGREDIENTS":
                                    {
                                        style_ingredients_text = nodes.InnerText;
                                        break;
                                    }
                                case "EXAMPLES":
                                    {
                                        style_examples_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MIN":
                                    {
                                        style_display_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MAX":
                                    {
                                        style_display_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MIN":
                                    {
                                        style_display_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MAX":
                                    {
                                        style_display_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MIN":
                                    {
                                        style_display_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MAX":
                                    {
                                        style_display_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_RANGE":
                                    {
                                        style_og_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_RANGE":
                                    {
                                        style_fg_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_RANGE":
                                    {
                                        style_ibu_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_RANGE":
                                    {
                                        style_carb_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_RANGE":
                                    {
                                        style_color_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_RANGE":
                                    {
                                        style_abv_range_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }

                    }
                    XmlElement style_name = documentRecipe.CreateElement("NAME");
                    style_name.InnerText = style_name_text;

                    XmlElement style_version = documentRecipe.CreateElement("VERSION");
                    style_version.InnerText = style_version_text;

                    XmlElement style_category = documentRecipe.CreateElement("CATEGORY");
                    style_category.InnerText = style_category_text;

                    XmlElement style_category_number = documentRecipe.CreateElement("CATEGORY_NUMBER");
                    style_category_number.InnerText = style_category_number_text;

                    XmlElement style_style_letter = documentRecipe.CreateElement("STYLE_LETTER");
                    style_style_letter.InnerText = style_style_letter_text;

                    XmlElement style_style_guide = documentRecipe.CreateElement("STYLE_GUIDE");
                    style_style_guide.InnerText = style_style_guide_text;

                    XmlElement style_type = documentRecipe.CreateElement("TYPE");
                    style_type.InnerText = style_type_text;

                    XmlElement style_og_min = documentRecipe.CreateElement("OG_MIN");
                    style_og_min.InnerText = style_og_min_text;

                    XmlElement style_og_max = documentRecipe.CreateElement("OG_MAX");
                    style_og_max.InnerText = style_og_max_text;

                    XmlElement style_fg_min = documentRecipe.CreateElement("FG_MIN");
                    style_fg_min.InnerText = style_fg_min_text;

                    XmlElement style_fg_max = documentRecipe.CreateElement("FG_MAX");
                    style_fg_max.InnerText = style_fg_max_text;

                    XmlElement style_ibu_min = documentRecipe.CreateElement("IBU_MIN");
                    style_ibu_min.InnerText = style_ibu_min_text;

                    XmlElement style_ibu_max = documentRecipe.CreateElement("IBU_MAX");
                    style_ibu_max.InnerText = style_ibu_max_text;

                    XmlElement style_color_min = documentRecipe.CreateElement("COLOR_MIN");
                    style_color_min.InnerText = style_color_min_text;

                    XmlElement style_color_max = documentRecipe.CreateElement("COLOR_MAX");
                    style_color_max.InnerText = style_color_max_text;

                    XmlElement style_carb_min = documentRecipe.CreateElement("CARB_MIN");
                    style_carb_min.InnerText = style_carb_min_text;

                    XmlElement style_carb_max = documentRecipe.CreateElement("CARB_MAX");
                    style_carb_max.InnerText = style_carb_max_text;

                    XmlElement style_abv_max = documentRecipe.CreateElement("ABV_MAX");
                    style_abv_max.InnerText = style_abv_max_text;

                    XmlElement style_abv_min = documentRecipe.CreateElement("ABV_MIN");
                    style_abv_min.InnerText = style_abv_min_text;

                    XmlElement style_notes = documentRecipe.CreateElement("NOTES");
                    style_notes.InnerText = style_notes_text;

                    XmlElement style_profile = documentRecipe.CreateElement("PROFILE");
                    style_profile.InnerText = style_profile_text;

                    XmlElement style_ingredients = documentRecipe.CreateElement("INGREDIENTS");
                    style_ingredients.InnerText = style_ingredients_text;

                    XmlElement style_examples = documentRecipe.CreateElement("EXAMPLES");
                    style_examples.InnerText = style_examples_text;

                    XmlElement style_display_og_min = documentRecipe.CreateElement("DISPLAY_OG_MIN");
                    style_display_og_min.InnerText = style_display_og_min_text;

                    XmlElement style_display_og_max = documentRecipe.CreateElement("DISPLAY_OG_MAX");
                    style_display_og_max.InnerText = style_display_og_max_text;

                    XmlElement style_display_fg_min = documentRecipe.CreateElement("DISPLAY_FG_MIN");
                    style_display_fg_min.InnerText = style_display_fg_min_text;

                    XmlElement style_display_fg_max = documentRecipe.CreateElement("DISPLAY_FG_MAX");
                    style_display_fg_max.InnerText = style_display_fg_max_text;

                    XmlElement style_display_color_min = documentRecipe.CreateElement("DISPLAY_COLOR_MIN");
                    style_display_color_min.InnerText = style_display_color_min_text;

                    XmlElement style_display_color_max = documentRecipe.CreateElement("DISPLAY_COLOR_MAX");
                    style_display_color_max.InnerText = style_display_color_max_text;

                    XmlElement style_og_range = documentRecipe.CreateElement("OG_RANGE");
                    style_og_range.InnerText = style_og_range_text;

                    XmlElement style_fg_range = documentRecipe.CreateElement("FG_RANGE");
                    style_fg_range.InnerText = style_fg_range_text;

                    XmlElement style_ibu_range = documentRecipe.CreateElement("IBU_RANGE");
                    style_ibu_range.InnerText = style_ibu_range_text;

                    XmlElement style_carb_range = documentRecipe.CreateElement("CARB_RANGE");
                    style_carb_range.InnerText = style_carb_range_text;

                    XmlElement style_color_range = documentRecipe.CreateElement("COLOR_RANGE");
                    style_color_range.InnerText = style_color_range_text;

                    XmlElement style_abv_range = documentRecipe.CreateElement("ABV_RANGE");
                    style_abv_range.InnerText = style_abv_range_text;

                    node.ChildNodes[14].AppendChild(style_name);
                    node.ChildNodes[14].AppendChild(style_version);
                    node.ChildNodes[14].AppendChild(style_category);
                    node.ChildNodes[14].AppendChild(style_category_number);
                    node.ChildNodes[14].AppendChild(style_style_letter);
                    node.ChildNodes[14].AppendChild(style_style_guide);
                    node.ChildNodes[14].AppendChild(style_type);
                    node.ChildNodes[14].AppendChild(style_og_min);
                    node.ChildNodes[14].AppendChild(style_og_max);
                    node.ChildNodes[14].AppendChild(style_fg_min);
                    node.ChildNodes[14].AppendChild(style_fg_max);
                    node.ChildNodes[14].AppendChild(style_ibu_min);
                    node.ChildNodes[14].AppendChild(style_ibu_max);
                    node.ChildNodes[14].AppendChild(style_color_min);
                    node.ChildNodes[14].AppendChild(style_color_max);
                    node.ChildNodes[14].AppendChild(style_carb_min);
                    node.ChildNodes[14].AppendChild(style_carb_max);
                    node.ChildNodes[14].AppendChild(style_abv_max);
                    node.ChildNodes[14].AppendChild(style_abv_min);
                    node.ChildNodes[14].AppendChild(style_notes);
                    node.ChildNodes[14].AppendChild(style_profile);
                    node.ChildNodes[14].AppendChild(style_ingredients);
                    node.ChildNodes[14].AppendChild(style_examples);
                    node.ChildNodes[14].AppendChild(style_display_og_min);
                    node.ChildNodes[14].AppendChild(style_display_og_max);
                    node.ChildNodes[14].AppendChild(style_display_fg_min);
                    node.ChildNodes[14].AppendChild(style_display_fg_max);
                    node.ChildNodes[14].AppendChild(style_display_color_min);
                    node.ChildNodes[14].AppendChild(style_display_color_max);
                    node.ChildNodes[14].AppendChild(style_og_range);
                    node.ChildNodes[14].AppendChild(style_fg_range);
                    node.ChildNodes[14].AppendChild(style_ibu_range);
                    node.ChildNodes[14].AppendChild(style_carb_range);
                    node.ChildNodes[14].AppendChild(style_color_range);
                    node.ChildNodes[14].AppendChild(style_abv_range);
                    //Equipment
                    //node.ChildNodes[15].InnerText = "equipment";
                    if (cbbEquipmentRecipes.Text == "")
                    {
                        message.title = "Error";
                        message.Content = "Please choose euipment";
                        message.ShowDialog();
                        return;
                    }
                    node.ChildNodes[15].RemoveAll();
                    XmlNode equipment_root = documentEquipment.DocumentElement;
                    XmlNode equipment_node = equipment_root.SelectSingleNode("descendant::EQUIPMENT[NAME='" + cbbEquipmentRecipes.Text + "']");
                    string equipment_name_text = "";
                    string equipment_version_text = "1";
                    string equipment_boil_size_text = "0.000";
                    string equipment_batch_size_text = "0.000";
                    string equipment_tun_volume_text = "0.000";
                    string equipment_tun_weight_text = "0.000";
                    string equipment_tun_specific_heat_text = "0.000";
                    string equipment_top_up_water_text = "0.000";
                    string equipment_trub_chiller_loss_text = "0.000";
                    string equipment_evap_rate_text = "0.000";
                    string equipment_boil_time_text = "0.000";
                    string equipment_calc_boil_volume_text = "FALSE";
                    string equipment_lauter_deadspace_text = "0.000";
                    string equipment_top_up_kettle_text = "0.000";
                    string equipment_hop_utilization_text = "0.000";
                    string equipment_notes_text = "";
                    string equipment_display_boil_size_text = "";
                    string equipment_display_batch_size_text = "";
                    string equipment_display_tun_volume_text = "";
                    string equipment_display_tun_weight_text = "";
                    string equipment_display_top_up_water_text = "";
                    string equipment_display_trub_chiller_loss_text = "";
                    string equipment_display_lauter_deadspace_text = "";
                    string equipment_display_top_up_kettle_text = "";

                    if (equipment_node != null)
                    {
                        foreach (XmlNode nodes in equipment_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        equipment_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        equipment_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_SIZE":
                                    {
                                        equipment_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "BATCH_SIZE":
                                    {
                                        equipment_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_VOLUME":
                                    {
                                        equipment_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_WEIGHT":
                                    {
                                        equipment_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_SPECIFIC_HEAT":
                                    {
                                        equipment_tun_specific_heat_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_WATER":
                                    {
                                        equipment_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "TRUB_CHILLER_LOSS":
                                    {
                                        equipment_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "EVAP_RATE":
                                    {
                                        equipment_evap_rate_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_TIME":
                                    {
                                        equipment_boil_time_text = nodes.InnerText;
                                        break;
                                    }
                                case "CALC_BOIL_VOLUME":
                                    {
                                        equipment_calc_boil_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "LAUTER_DEADSPACE":
                                    {
                                        equipment_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_KETTLE":
                                    {
                                        equipment_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                                case "HOP_UTILIZATION":
                                    {
                                        equipment_hop_utilization_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        equipment_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BOIL_SIZE":
                                    {
                                        equipment_display_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BATCH_SIZE":
                                    {
                                        equipment_display_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_VOLUME":
                                    {
                                        equipment_display_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_WEIGHT":
                                    {
                                        equipment_display_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_WATER":
                                    {
                                        equipment_display_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TRUB_CHILLER_LOSS":
                                    {
                                        equipment_display_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_LAUTER_DEADSPACE":
                                    {
                                        equipment_display_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_KETTLE":
                                    {
                                        equipment_display_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }
                    }
                    XmlElement equipment_name = documentRecipe.CreateElement("NAME");
                    equipment_name.InnerText = equipment_name_text;

                    XmlElement equipment_version = documentRecipe.CreateElement("VERSION");
                    equipment_version.InnerText = equipment_version_text;

                    XmlElement equipment_boil_size = documentRecipe.CreateElement("BOIL_SIZE");
                    equipment_boil_size.InnerText = equipment_boil_size_text;

                    XmlElement equipment_batch_size = documentRecipe.CreateElement("BATCH_SIZE");
                    equipment_batch_size.InnerText = equipment_batch_size_text;

                    XmlElement equipment_tun_volume = documentRecipe.CreateElement("TUN_VOLUME");
                    equipment_tun_volume.InnerText = equipment_tun_volume_text;

                    XmlElement equipment_tun_weight = documentRecipe.CreateElement("TUN_WEIGHT");
                    equipment_tun_weight.InnerText = equipment_tun_weight_text;

                    XmlElement equipment_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    equipment_tun_specific_heat.InnerText = equipment_tun_specific_heat_text;

                    XmlElement equipment_top_up_water = documentRecipe.CreateElement("TOP_UP_WATER");
                    equipment_top_up_water.InnerText = equipment_top_up_water_text;

                    XmlElement equipment_trub_chiller_loss = documentRecipe.CreateElement("TRUB_CHILLER_LOSS");
                    equipment_trub_chiller_loss.InnerText = equipment_trub_chiller_loss_text;

                    XmlElement equipment_evap_rate = documentRecipe.CreateElement("EVAP_RATE");
                    equipment_evap_rate.InnerText = equipment_evap_rate_text;

                    XmlElement equipment_boil_time = documentRecipe.CreateElement("BOIL_TIME");
                    equipment_boil_time.InnerText = equipment_boil_time_text;

                    XmlElement equipment_calc_boil_volume = documentRecipe.CreateElement("CALC_BOIL_VOLUME");
                    equipment_calc_boil_volume.InnerText = equipment_calc_boil_volume_text;

                    XmlElement equipment_lauter_deadspace = documentRecipe.CreateElement("LAUTER_DEADSPACE");
                    equipment_lauter_deadspace.InnerText = equipment_lauter_deadspace_text;

                    XmlElement equipment_top_up_kettle = documentRecipe.CreateElement("TOP_UP_KETTLE");
                    equipment_top_up_kettle.InnerText = equipment_top_up_kettle_text;

                    XmlElement equipment_hop_utilization = documentRecipe.CreateElement("HOP_UTILIZATION");
                    equipment_hop_utilization.InnerText = equipment_hop_utilization_text;

                    XmlElement equipment_notes = documentRecipe.CreateElement("NOTES");
                    equipment_notes.InnerText = equipment_notes_text;

                    XmlElement equipment_display_boil_size = documentRecipe.CreateElement("DISPLAY_BOIL_SIZE");
                    equipment_display_boil_size.InnerText = equipment_display_boil_size_text;

                    XmlElement equipment_display_batch_size = documentRecipe.CreateElement("DISPLAY_BATCH_SIZE");
                    equipment_display_batch_size.InnerText = equipment_display_batch_size_text;

                    XmlElement equipment_display_tun_volume = documentRecipe.CreateElement("DISPLAY_TUN_VOLUME");
                    equipment_display_tun_volume.InnerText = equipment_display_tun_volume_text;

                    XmlElement equipment_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    equipment_display_tun_weight.InnerText = equipment_display_tun_weight_text;

                    XmlElement equipment_display_top_up_water = documentRecipe.CreateElement("DISPLAY_TOP_UP_WATER");
                    equipment_display_top_up_water.InnerText = equipment_display_top_up_water_text;

                    XmlElement equipment_display_trub_chiller_loss = documentRecipe.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    equipment_display_trub_chiller_loss.InnerText = equipment_display_trub_chiller_loss_text;

                    XmlElement equipment_display_lauter_deadspace = documentRecipe.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    equipment_display_lauter_deadspace.InnerText = equipment_display_lauter_deadspace_text;

                    XmlElement equipment_display_top_up_kettle = documentRecipe.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    equipment_display_top_up_kettle.InnerText = equipment_display_top_up_kettle_text;

                    node.ChildNodes[15].AppendChild(equipment_name);
                    node.ChildNodes[15].AppendChild(equipment_version);
                    node.ChildNodes[15].AppendChild(equipment_boil_size);
                    node.ChildNodes[15].AppendChild(equipment_batch_size);
                    node.ChildNodes[15].AppendChild(equipment_tun_volume);
                    node.ChildNodes[15].AppendChild(equipment_tun_weight);
                    node.ChildNodes[15].AppendChild(equipment_tun_specific_heat);
                    node.ChildNodes[15].AppendChild(equipment_top_up_water);
                    node.ChildNodes[15].AppendChild(equipment_trub_chiller_loss);
                    node.ChildNodes[15].AppendChild(equipment_evap_rate);
                    node.ChildNodes[15].AppendChild(equipment_boil_time);
                    node.ChildNodes[15].AppendChild(equipment_calc_boil_volume);
                    node.ChildNodes[15].AppendChild(equipment_lauter_deadspace);
                    node.ChildNodes[15].AppendChild(equipment_top_up_kettle);
                    node.ChildNodes[15].AppendChild(equipment_hop_utilization);
                    node.ChildNodes[15].AppendChild(equipment_notes);
                    node.ChildNodes[15].AppendChild(equipment_display_boil_size);
                    node.ChildNodes[15].AppendChild(equipment_display_batch_size);
                    node.ChildNodes[15].AppendChild(equipment_display_tun_volume);
                    node.ChildNodes[15].AppendChild(equipment_display_tun_weight);
                    node.ChildNodes[15].AppendChild(equipment_display_top_up_water);
                    node.ChildNodes[15].AppendChild(equipment_display_trub_chiller_loss);
                    node.ChildNodes[15].AppendChild(equipment_display_lauter_deadspace);
                    node.ChildNodes[15].AppendChild(equipment_display_top_up_kettle);

                    //Mash
                    //node.ChildNodes[16].InnerText = "mash";
                    //XmlElement mash = documentRecipe.CreateElement("MASH");
                    node.ChildNodes[16].RemoveAll();
                    XmlElement mash_name = documentRecipe.CreateElement("NAME");
                    mash_name.InnerText = "Single Infusion";

                    XmlElement mash_version = documentRecipe.CreateElement("VERSION");
                    mash_version.InnerText = "1";

                    XmlElement mash_grain_temp = documentRecipe.CreateElement("GRAIN_TEMP");
                    mash_grain_temp.InnerText = "22.22222200";

                    XmlElement mash_tun_temp = documentRecipe.CreateElement("TUN_TEMP");
                    mash_tun_temp.InnerText = "22.22222200";

                    XmlElement mash_sparge_temp = documentRecipe.CreateElement("SPARGE_TEMP");
                    mash_sparge_temp.InnerText = "75.55555600";

                    XmlElement mash_ph = documentRecipe.CreateElement("PH");
                    mash_ph.InnerText = "5.4";

                    XmlElement mash_tun_weigth = documentRecipe.CreateElement("TUN_WEIGHT");
                    mash_tun_weigth.InnerText = "1.81436800";

                    XmlElement mash_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    mash_tun_specific_heat.InnerText = "0.30000000";

                    XmlElement mash_equip_adjust = documentRecipe.CreateElement("EQUIP_ADJUST");
                    mash_equip_adjust.InnerText = "FALSE";

                    XmlElement mash_notes = documentRecipe.CreateElement("NOTES");
                    mash_notes.InnerText = "";

                    XmlElement mash_display_grain_temp = documentRecipe.CreateElement("DISPLAY_GRAIN_TEMP");
                    mash_display_grain_temp.InnerText = "72.0 F";

                    XmlElement mash_display_tun_temp = documentRecipe.CreateElement("DISPLAY_TUN_TEMP");
                    mash_display_tun_temp.InnerText = "72.0";

                    XmlElement mash_display_sparge_temp = documentRecipe.CreateElement("DISPLAY_SPARGE_TEMP");
                    mash_display_sparge_temp.InnerText = "168.0 F";

                    XmlElement mash_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    mash_display_tun_weight.InnerText = "4.00 lb";

                    XmlElement mash_mash_steps = documentRecipe.CreateElement("MASH_STEPS");
                    if (tableViewMashRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewMashRecipes.DataRowCount; i++)
                        {
                            XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                            mash_step_name.InnerText = tableViewMashRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                            mash_step_version.InnerText = tableViewMashRecipes.GetRowCellValue(i, "version").ToString();

                            XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                            mash_step_type.InnerText = tableViewMashRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_amount").ToString();

                            XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_time").ToString();

                            XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_temp").ToString();

                            XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "ramp_time").ToString();

                            XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "end_temp").ToString();

                            XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = tableViewMashRecipes.GetRowCellValue(i, "description").ToString();

                            XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = tableViewMashRecipes.GetRowCellValue(i, "water_grain_ratio").ToString();

                            XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "decoction_amt").ToString();

                            XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_temp").ToString();

                            XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_step_temp").ToString();

                            XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_infuse_amt").ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            mash_mash_steps.AppendChild(mash_step);
                        }
                    }
                    else
                    {
                        XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                        mash_step_name.InnerText = "Mash Out";

                        XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                        mash_step_version.InnerText = "1";

                        XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                        mash_step_type.InnerText = "Infusion";

                        XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = "6.81378";

                        XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = "10";

                        XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = "0";

                        XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = "2";

                        XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = "75.55556";

                        XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = "";

                        XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = "2.05";

                        XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = "0.00 qt";

                        XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = "185.9 F";

                        XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = "";

                        XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = "7.20 qt";


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_mash_steps.AppendChild(mash_step);
                    }
                    
                    node.ChildNodes[16].AppendChild(mash_name);
                    node.ChildNodes[16].AppendChild(mash_version);
                    node.ChildNodes[16].AppendChild(mash_grain_temp);
                    node.ChildNodes[16].AppendChild(mash_tun_temp);
                    node.ChildNodes[16].AppendChild(mash_sparge_temp);
                    node.ChildNodes[16].AppendChild(mash_ph);
                    node.ChildNodes[16].AppendChild(mash_tun_weigth);
                    node.ChildNodes[16].AppendChild(mash_tun_specific_heat);
                    node.ChildNodes[16].AppendChild(mash_equip_adjust);
                    node.ChildNodes[16].AppendChild(mash_notes);
                    node.ChildNodes[16].AppendChild(mash_display_grain_temp);
                    node.ChildNodes[16].AppendChild(mash_display_tun_temp);
                    node.ChildNodes[16].AppendChild(mash_display_sparge_temp);
                    node.ChildNodes[16].AppendChild(mash_display_tun_weight);
                    node.ChildNodes[16].AppendChild(mash_mash_steps);

                    node.ChildNodes[17].InnerText = txtNotesRecipes.Text;
                    node.ChildNodes[18].InnerText = txtTasteNotesRecipes.Text;
                    node.ChildNodes[19].InnerText = txtTasteRatingRecipes.Text;
                    node.ChildNodes[20].InnerText = lbOGRecipes.Text;
                    node.ChildNodes[21].InnerText = lbFGRecipes.Text;
                    node.ChildNodes[22].InnerText = txtCarbonationVolumesRecipes.Text;
                    node.ChildNodes[23].InnerText = "2";
                    node.ChildNodes[24].InnerText = "0";
                    node.ChildNodes[25].InnerText = txtPrimaryAgeRecipes.Text.Replace("s","");
                    node.ChildNodes[26].InnerText = txtPrimaryTempRecipes.Text.Replace("C","");
                    node.ChildNodes[27].InnerText = txtSecondaryAgeRecipes.Text.Replace("s","");
                    node.ChildNodes[28].InnerText = txtSecondaryTempRecipes.Text.Replace("C","");
                    node.ChildNodes[29].InnerText = txtTertiaryAgeRecipes.Text;
                    node.ChildNodes[30].InnerText = txtBottleKeyAgeRecipes.Text.Replace("s","");
                    node.ChildNodes[31].InnerText = txtBottleKeyTempRecipes.Text.Replace("C", "");
                    node.ChildNodes[32].InnerText = "12 PSI";
                    node.ChildNodes[33].InnerText = cbbdateDateFirstBrewedRecipes.Text;
                    node.ChildNodes[34].InnerText = lbOGRecipes.Text;
                    node.ChildNodes[35].InnerText = lbFGRecipes.Text;
                    node.ChildNodes[36].InnerText = lbIBURecipes.Text;
                    node.ChildNodes[37].InnerText = "Tinseth";
                    node.ChildNodes[38].InnerText = lbBitternessRecipes.Text;
                    node.ChildNodes[39].InnerText = lbABVRecipes.Text;
                    node.ChildNodes[40].InnerText = "5.1 %";
                    node.ChildNodes[41].InnerText = "69.7 %";
                    node.ChildNodes[42].InnerText = "242 cal/pint";
                    node.ChildNodes[43].InnerText = "5.00 gal";
                    node.ChildNodes[44].InnerText = "1.054 SG";
                    node.ChildNodes[45].InnerText = "1.015 SG";
                    node.ChildNodes[46].InnerText = "68.0 F";
                    node.ChildNodes[47].InnerText = "68.0 F";
                    node.ChildNodes[48].InnerText = "68.0 F";
                    node.ChildNodes[49].InnerText = "52.0 F";

                    try
                    {
                        fsRecipes = new FileStream(fileRecipes, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }

                    documentRecipe.Save(fsRecipes);
                    message.title = "Update Recipe";
                    message.Content = "Update success";
                    message.ShowDialog();
                    fsRecipes.Close();
                }
                else
                {
                    XmlElement recipe = documentRecipe.CreateElement("RECIPE");

                    XmlElement name = documentRecipe.CreateElement("NAME");
                    name.InnerText = txtRecipes.Text;

                    XmlElement version = documentRecipe.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = documentRecipe.CreateElement("TYPE");
                    type.InnerText = "All Grain";

                    XmlElement brewer = documentRecipe.CreateElement("BREWER");
                    brewer.InnerText = txtBrewerRecipes.Text;

                    XmlElement asst_brewer = documentRecipe.CreateElement("ASST_BREWER");
                    asst_brewer.InnerText = txtAsstBrewerRecipes.Text;

                    XmlElement batch_size = documentRecipe.CreateElement("BATCH_SIZE");
                    batch_size.InnerText = txtTargetBatchSizeRecipes.Text.Replace("L","");

                    XmlElement boil_size = documentRecipe.CreateElement("BOIL_SIZE");
                    boil_size.InnerText = txtTargetBoilSizeRecipes.Text.Replace("L","");

                    XmlElement boil_time = documentRecipe.CreateElement("BOIL_TIME");
                    boil_time.InnerText = txtBoilTimeRecipes.Text.Replace("s","");

                    XmlElement efficiency = documentRecipe.CreateElement("EFFICIENCY");
                    efficiency.InnerText = txtEfficiencyRecipes.Text;

                    //HOPS
                    XmlElement hops = documentRecipe.CreateElement("HOPS");
                    if (tableViewHopsRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewHopsRecipes.DataRowCount; i++)
                        {
                            XmlElement hop = documentRecipe.CreateElement("HOP");

                            XmlElement hop_name = documentRecipe.CreateElement("NAME");
                            hop_name.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement hop_version = documentRecipe.CreateElement("VERSION");
                            try
                            {
                                hop_version.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "version").ToString();
                            }
                            catch (Exception)
                            {
                                hop_version.InnerText = "1";
                            }

                            XmlElement hop_origin = documentRecipe.CreateElement("ORIGIN");
                            hop_origin.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "origin").ToString();

                            XmlElement hop_alpha = documentRecipe.CreateElement("ALPHA");
                            hop_alpha.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "alpha").ToString();

                            XmlElement hop_amount = documentRecipe.CreateElement("AMOUNT");
                            hop_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement hop_use = documentRecipe.CreateElement("USE");
                            hop_use.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "use").ToString();

                            XmlElement hop_time = documentRecipe.CreateElement("TIME");
                            hop_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "time").ToString();

                            XmlElement hop_notes = documentRecipe.CreateElement("NOTES");
                            hop_notes.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement hop_type = documentRecipe.CreateElement("TYPE");
                            hop_type.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement hop_form = documentRecipe.CreateElement("FORM");
                            hop_form.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "form").ToString();

                            XmlElement hop_beta = documentRecipe.CreateElement("BETA");
                            hop_beta.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "beta").ToString();

                            XmlElement hop_hsi = documentRecipe.CreateElement("HSI");
                            hop_hsi.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "hsi").ToString();

                            XmlElement hop_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            hop_display_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement hop_inventory = documentRecipe.CreateElement("INVENTORY");
                            hop_inventory.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement hop_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                            hop_display_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_time").ToString();

                            hop.AppendChild(hop_name);
                            hop.AppendChild(hop_version);
                            hop.AppendChild(hop_origin);
                            hop.AppendChild(hop_alpha);
                            hop.AppendChild(hop_amount);
                            hop.AppendChild(hop_use);
                            hop.AppendChild(hop_time);
                            hop.AppendChild(hop_notes);
                            hop.AppendChild(hop_type);
                            hop.AppendChild(hop_form);
                            hop.AppendChild(hop_beta);
                            hop.AppendChild(hop_hsi);
                            hop.AppendChild(hop_display_amount);
                            hop.AppendChild(hop_inventory);
                            hop.AppendChild(hop_display_time);

                            hops.AppendChild(hop);
                        }

                    }
                    else
                    {
                        XmlElement hop = documentRecipe.CreateElement("HOP");

                        XmlElement hop_name = documentRecipe.CreateElement("NAME");
                        hop_name.InnerText = "Fuggles";

                        XmlElement hop_version = documentRecipe.CreateElement("VERSION");
                        hop_version.InnerText = "1";

                        XmlElement hop_origin = documentRecipe.CreateElement("ORIGIN");
                        hop_origin.InnerText = "Germany";

                        XmlElement hop_alpha = documentRecipe.CreateElement("ALPHA");
                        hop_alpha.InnerText = "7.5";

                        XmlElement hop_amount = documentRecipe.CreateElement("AMOUNT");
                        hop_amount.InnerText = "0.014175";

                        XmlElement hop_use = documentRecipe.CreateElement("USE");
                        hop_use.InnerText = "Boil";

                        XmlElement hop_time = documentRecipe.CreateElement("TIME");
                        hop_time.InnerText = "60";

                        XmlElement hop_notes = documentRecipe.CreateElement("NOTES");
                        hop_notes.InnerText = "";

                        XmlElement hop_type = documentRecipe.CreateElement("TYPE");
                        hop_type.InnerText = "Both";

                        XmlElement hop_form = documentRecipe.CreateElement("FORM");
                        hop_form.InnerText = "Pellet";

                        XmlElement hop_beta = documentRecipe.CreateElement("BETA");
                        hop_beta.InnerText = "4";

                        XmlElement hop_hsi = documentRecipe.CreateElement("HSI");
                        hop_hsi.InnerText = "35";

                        XmlElement hop_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        hop_display_amount.InnerText = "0.00 oz";

                        XmlElement hop_inventory = documentRecipe.CreateElement("INVENTORY");
                        hop_inventory.InnerText = "0.00 oz";

                        XmlElement hop_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        hop_display_time.InnerText = "-";

                        hop.AppendChild(hop_name);
                        hop.AppendChild(hop_version);
                        hop.AppendChild(hop_origin);
                        hop.AppendChild(hop_alpha);
                        hop.AppendChild(hop_amount);
                        hop.AppendChild(hop_use);
                        hop.AppendChild(hop_time);
                        hop.AppendChild(hop_notes);
                        hop.AppendChild(hop_type);
                        hop.AppendChild(hop_form);
                        hop.AppendChild(hop_beta);
                        hop.AppendChild(hop_hsi);
                        hop.AppendChild(hop_display_amount);
                        hop.AppendChild(hop_inventory);
                        hop.AppendChild(hop_display_time);

                        hops.AppendChild(hop);
                    }
                    
                    //FERMENTABLE
                    XmlElement fermentables = documentRecipe.CreateElement("FERMENTABLES");
                    if (tableViewFermentablesRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
                        {
                            XmlElement fermentable = documentRecipe.CreateElement("FERMENTABLE");

                            XmlElement fermentable_name = documentRecipe.CreateElement("NAME");
                            fermentable_name.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement fermentable_version = documentRecipe.CreateElement("VERSION");
                            try
                            {
                                fermentable_version.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "version").ToString();
                            }
                            catch (Exception)
                            {
                                fermentable_version.InnerText = "1";
                            }

                            XmlElement fermentable_type = documentRecipe.CreateElement("TYPE");
                            fermentable_type.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement fermentable_amount = documentRecipe.CreateElement("AMOUNT");
                            fermentable_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement fermentable_yield = documentRecipe.CreateElement("YIELD");
                            fermentable_yield.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "yield").ToString();

                            XmlElement fermentable_color = documentRecipe.CreateElement("COLOR");
                            fermentable_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString();

                            XmlElement fermentable_add_after_boil = documentRecipe.CreateElement("ADD_AFTER_BOIL");
                            fermentable_add_after_boil.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "add_after_boil").ToString();

                            XmlElement fermentable_origin = documentRecipe.CreateElement("ORIGIN");
                            fermentable_origin.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "origin").ToString();

                            XmlElement fermentable_supplier = documentRecipe.CreateElement("SUPPLIER");
                            fermentable_supplier.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "supplier").ToString();

                            XmlElement fermentable_notes = documentRecipe.CreateElement("NOTES");
                            fermentable_notes.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement fermentable_coarse_fine_diff = documentRecipe.CreateElement("COARSE_FINE_DIFF");
                            fermentable_coarse_fine_diff.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "coarse_fine_diff").ToString();

                            XmlElement fermentable_moisture = documentRecipe.CreateElement("MOISTURE");
                            fermentable_moisture.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "moisture").ToString();

                            XmlElement fermentable_diastatic_power = documentRecipe.CreateElement("DIASTATIC_POWER");
                            fermentable_diastatic_power.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "diastatic_power").ToString();

                            XmlElement fermentable_protein = documentRecipe.CreateElement("PROTEIN");
                            fermentable_protein.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "protein").ToString();

                            XmlElement fermentable_max_in_batch = documentRecipe.CreateElement("MAX_IN_BATCH");
                            fermentable_max_in_batch.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "max_in_batch").ToString();

                            XmlElement fermentable_recommend_mash = documentRecipe.CreateElement("RECOMMEND_MASH");
                            fermentable_recommend_mash.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "recommend_mash").ToString();

                            XmlElement fermentable_ibu_gal_per_lb = documentRecipe.CreateElement("IBU_GAL_PER_LB");
                            fermentable_ibu_gal_per_lb.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "ibu_gal_per_lb").ToString();

                            XmlElement fermentable_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            fermentable_display_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement fermentable_inventory = documentRecipe.CreateElement("INVENTORY");
                            fermentable_inventory.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement fermentable_potential = documentRecipe.CreateElement("POTENTIAL");
                            fermentable_potential.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "potential").ToString();

                            XmlElement fermentable_display_color = documentRecipe.CreateElement("DISPLAY_COLOR");
                            fermentable_display_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_color").ToString();


                            fermentable.AppendChild(fermentable_name);
                            fermentable.AppendChild(fermentable_version);
                            fermentable.AppendChild(fermentable_type);
                            fermentable.AppendChild(fermentable_amount);
                            fermentable.AppendChild(fermentable_yield);
                            fermentable.AppendChild(fermentable_color);
                            fermentable.AppendChild(fermentable_add_after_boil);
                            fermentable.AppendChild(fermentable_origin);
                            fermentable.AppendChild(fermentable_supplier);
                            fermentable.AppendChild(fermentable_notes);
                            fermentable.AppendChild(fermentable_coarse_fine_diff);
                            fermentable.AppendChild(fermentable_moisture);
                            fermentable.AppendChild(fermentable_diastatic_power);
                            fermentable.AppendChild(fermentable_protein);
                            fermentable.AppendChild(fermentable_max_in_batch);
                            fermentable.AppendChild(fermentable_recommend_mash);
                            fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                            fermentable.AppendChild(fermentable_display_amount);
                            fermentable.AppendChild(fermentable_inventory);
                            fermentable.AppendChild(fermentable_potential);
                            fermentable.AppendChild(fermentable_display_color);
                            fermentables.AppendChild(fermentable);
                        }
                    }
                    else
                    {
                        XmlElement fermentable = documentRecipe.CreateElement("FERMENTABLE");

                        XmlElement fermentable_name = documentRecipe.CreateElement("NAME");
                        fermentable_name.InnerText = "Caramel/Crystal Malt - 20L";

                        XmlElement fermentable_version = documentRecipe.CreateElement("VERSION");
                        fermentable_version.InnerText = "1";

                        XmlElement fermentable_type = documentRecipe.CreateElement("TYPE");
                        fermentable_type.InnerText = "Grain";

                        XmlElement fermentable_amount = documentRecipe.CreateElement("AMOUNT");
                        fermentable_amount.InnerText = "0.453592";

                        XmlElement fermentable_yield = documentRecipe.CreateElement("YIELD");
                        fermentable_yield.InnerText = "75";

                        XmlElement fermentable_color = documentRecipe.CreateElement("COLOR");
                        fermentable_color.InnerText = "20";

                        XmlElement fermentable_add_after_boil = documentRecipe.CreateElement("ADD_AFTER_BOIL");
                        fermentable_add_after_boil.InnerText = "FALSE";

                        XmlElement fermentable_origin = documentRecipe.CreateElement("ORIGIN");
                        fermentable_origin.InnerText = "US";

                        XmlElement fermentable_supplier = documentRecipe.CreateElement("SUPPLIER");
                        fermentable_supplier.InnerText = "";

                        XmlElement fermentable_notes = documentRecipe.CreateElement("NOTES");
                        fermentable_notes.InnerText = "";

                        XmlElement fermentable_coarse_fine_diff = documentRecipe.CreateElement("COARSE_FINE_DIFF");
                        fermentable_coarse_fine_diff.InnerText = "1.5";

                        XmlElement fermentable_moisture = documentRecipe.CreateElement("MOISTURE");
                        fermentable_moisture.InnerText = "4";

                        XmlElement fermentable_diastatic_power = documentRecipe.CreateElement("DIASTATIC_POWER");
                        fermentable_diastatic_power.InnerText = "0";

                        XmlElement fermentable_protein = documentRecipe.CreateElement("PROTEIN");
                        fermentable_protein.InnerText = "13.2";

                        XmlElement fermentable_max_in_batch = documentRecipe.CreateElement("MAX_IN_BATCH");
                        fermentable_max_in_batch.InnerText = "20";

                        XmlElement fermentable_recommend_mash = documentRecipe.CreateElement("RECOMMEND_MASH");
                        fermentable_recommend_mash.InnerText = "FALSE";

                        XmlElement fermentable_ibu_gal_per_lb = documentRecipe.CreateElement("IBU_GAL_PER_LB");
                        fermentable_ibu_gal_per_lb.InnerText = "0";

                        XmlElement fermentable_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        fermentable_display_amount.InnerText = "0.00 lb";

                        XmlElement fermentable_inventory = documentRecipe.CreateElement("INVENTORY");
                        fermentable_inventory.InnerText = "0.00 lb";

                        XmlElement fermentable_potential = documentRecipe.CreateElement("POTENTIAL");
                        fermentable_potential.InnerText = "0.000";

                        XmlElement fermentable_display_color = documentRecipe.CreateElement("DISPLAY_COLOR");
                        fermentable_display_color.InnerText = "";


                        fermentable.AppendChild(fermentable_name);
                        fermentable.AppendChild(fermentable_version);
                        fermentable.AppendChild(fermentable_type);
                        fermentable.AppendChild(fermentable_amount);
                        fermentable.AppendChild(fermentable_yield);
                        fermentable.AppendChild(fermentable_color);
                        fermentable.AppendChild(fermentable_add_after_boil);
                        fermentable.AppendChild(fermentable_origin);
                        fermentable.AppendChild(fermentable_supplier);
                        fermentable.AppendChild(fermentable_notes);
                        fermentable.AppendChild(fermentable_coarse_fine_diff);
                        fermentable.AppendChild(fermentable_moisture);
                        fermentable.AppendChild(fermentable_diastatic_power);
                        fermentable.AppendChild(fermentable_protein);
                        fermentable.AppendChild(fermentable_max_in_batch);
                        fermentable.AppendChild(fermentable_recommend_mash);
                        fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                        fermentable.AppendChild(fermentable_display_amount);
                        fermentable.AppendChild(fermentable_inventory);
                        fermentable.AppendChild(fermentable_potential);
                        fermentable.AppendChild(fermentable_display_color);

                        fermentables.AppendChild(fermentable);
                    }
                    

                    //MISC
                    XmlElement miscs = documentRecipe.CreateElement("MISCS");
                    if (tableViewMiscRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewMiscRecipes.DataRowCount; i++)
                        {
                            XmlElement misc = documentRecipe.CreateElement("MISC");

                            XmlElement misc_name = documentRecipe.CreateElement("NAME");
                            misc_name.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                            misc_version.InnerText = "1";

                            XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                            misc_type.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement misc_use = documentRecipe.CreateElement("USE");
                            misc_use.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use").ToString();

                            XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                            misc_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement misc_time = documentRecipe.CreateElement("TIME");
                            misc_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "time").ToString();

                            XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                            misc_amount_is_weight.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                            XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                            misc_use_for.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use_for").ToString();

                            XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                            misc_notes.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            misc_display_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                            misc_inventory.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                            misc_display_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_time").ToString();

                            misc.AppendChild(misc_name);
                            misc.AppendChild(misc_version);
                            misc.AppendChild(misc_type);
                            misc.AppendChild(misc_use);
                            misc.AppendChild(misc_amount);
                            misc.AppendChild(misc_time);
                            misc.AppendChild(misc_amount_is_weight);
                            misc.AppendChild(misc_use_for);
                            misc.AppendChild(misc_notes);
                            misc.AppendChild(misc_display_amount);
                            misc.AppendChild(misc_inventory);
                            misc.AppendChild(misc_display_time);
                            miscs.AppendChild(misc);
                        }
                    }
                    else
                    {
                        XmlElement misc = documentRecipe.CreateElement("MISC");

                        XmlElement misc_name = documentRecipe.CreateElement("NAME");
                        misc_name.InnerText = "Orange Peel, Bitter";

                        XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                        misc_version.InnerText = "1";

                        XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                        misc_type.InnerText = "Spice";

                        XmlElement misc_use = documentRecipe.CreateElement("USE");
                        misc_use.InnerText = "Boil";

                        XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                        misc_amount.InnerText = "0.02218";

                        XmlElement misc_time = documentRecipe.CreateElement("TIME");
                        misc_time.InnerText = "60";

                        XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        misc_amount_is_weight.InnerText = "FALSE";

                        XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                        misc_use_for.InnerText = "Fruit Beer";

                        XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                        misc_notes.InnerText = "";

                        XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        misc_display_amount.InnerText = "6.50 oz";

                        XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                        misc_inventory.InnerText = "0.00 oz";

                        XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        misc_display_time.InnerText = "5.0 min";

                        misc.AppendChild(misc_name);
                        misc.AppendChild(misc_version);
                        misc.AppendChild(misc_type);
                        misc.AppendChild(misc_use);
                        misc.AppendChild(misc_amount);
                        misc.AppendChild(misc_time);
                        misc.AppendChild(misc_amount_is_weight);
                        misc.AppendChild(misc_use_for);
                        misc.AppendChild(misc_notes);
                        misc.AppendChild(misc_display_amount);
                        misc.AppendChild(misc_inventory);
                        misc.AppendChild(misc_display_time);
                        miscs.AppendChild(misc);
                    }

                    //YEAST
                    XmlElement yeasts = documentRecipe.CreateElement("YEASTS");
                    if (tableViewYeastRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewYeastRecipes.DataRowCount; i++)
                        {
                            XmlElement yeast = documentRecipe.CreateElement("YEAST");

                            XmlElement yeast_name = documentRecipe.CreateElement("NAME");
                            yeast_name.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement yeast_version = documentRecipe.CreateElement("VERSION");
                            yeast_version.InnerText = "1";

                            XmlElement yeast_type = documentRecipe.CreateElement("TYPE");
                            yeast_type.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement yeast_form = documentRecipe.CreateElement("FORM");
                            yeast_form.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "form").ToString();

                            XmlElement yeast_amount = documentRecipe.CreateElement("AMOUNT");
                            yeast_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount").ToString();

                            XmlElement yeast_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                            yeast_amount_is_weight.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                            XmlElement yeast_laboratory = documentRecipe.CreateElement("LABORATORY");
                            yeast_laboratory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "laboratory").ToString();

                            XmlElement yeast_product_id = documentRecipe.CreateElement("PRODUCT_ID");
                            yeast_product_id.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "product_id").ToString();

                            XmlElement yeast_min_temperature = documentRecipe.CreateElement("MIN_TEMPERATURE");
                            yeast_min_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "min_temperature").ToString();

                            XmlElement yeast_max_temperature = documentRecipe.CreateElement("MAX_TEMPERATURE");
                            yeast_max_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_temperature").ToString();

                            XmlElement yeast_flocculation = documentRecipe.CreateElement("FLOCCULATION");
                            yeast_flocculation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "flocculation").ToString();

                            XmlElement yeast_attenuation = documentRecipe.CreateElement("ATTENUATION");
                            yeast_attenuation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "attenuation").ToString();

                            XmlElement yeast_notes = documentRecipe.CreateElement("NOTES");
                            yeast_notes.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "notes").ToString();

                            XmlElement yeast_best_for = documentRecipe.CreateElement("BEST_FOR");
                            yeast_best_for.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "best_for").ToString();

                            XmlElement yeast_max_reuse = documentRecipe.CreateElement("MAX_REUSE");
                            yeast_max_reuse.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_reuse").ToString();

                            XmlElement yeast_times_cultured = documentRecipe.CreateElement("TIMES_CULTURED");
                            yeast_times_cultured.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "times_cultured").ToString();

                            XmlElement yeast_add_to_secondary = documentRecipe.CreateElement("ADD_TO_SECONDARY");
                            yeast_add_to_secondary.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "add_to_secondary").ToString();

                            XmlElement yeast_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            yeast_display_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "display_amount").ToString();

                            XmlElement yeast_disp_min_temp = documentRecipe.CreateElement("DISP_MIN_TEMP");
                            yeast_disp_min_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_min_temp").ToString();

                            XmlElement yeast_disp_max_temp = documentRecipe.CreateElement("DISP_MAX_TEMP");
                            yeast_disp_max_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_max_temp").ToString();

                            XmlElement yeast_inventory = documentRecipe.CreateElement("INVENTORY");
                            yeast_inventory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "inventory").ToString();

                            XmlElement yeast_culture_date = documentRecipe.CreateElement("CULTURE_DATE");
                            yeast_culture_date.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "culture_date").ToString();


                            yeast.AppendChild(yeast_name);
                            yeast.AppendChild(yeast_version);
                            yeast.AppendChild(yeast_type);
                            yeast.AppendChild(yeast_form);
                            yeast.AppendChild(yeast_amount);
                            yeast.AppendChild(yeast_amount_is_weight);
                            yeast.AppendChild(yeast_laboratory);
                            yeast.AppendChild(yeast_product_id);
                            yeast.AppendChild(yeast_min_temperature);
                            yeast.AppendChild(yeast_max_temperature);
                            yeast.AppendChild(yeast_flocculation);
                            yeast.AppendChild(yeast_attenuation);
                            yeast.AppendChild(yeast_notes);
                            yeast.AppendChild(yeast_best_for);
                            yeast.AppendChild(yeast_max_reuse);
                            yeast.AppendChild(yeast_times_cultured);
                            yeast.AppendChild(yeast_add_to_secondary);
                            yeast.AppendChild(yeast_display_amount);
                            yeast.AppendChild(yeast_disp_min_temp);
                            yeast.AppendChild(yeast_disp_max_temp);
                            yeast.AppendChild(yeast_inventory);
                            yeast.AppendChild(yeast_culture_date);

                            yeasts.AppendChild(yeast);
                        }
                    }
                    else
                    {
                        XmlElement yeast = documentRecipe.CreateElement("YEAST");

                        XmlElement yeast_name = documentRecipe.CreateElement("NAME");
                        yeast_name.InnerText = "Northwest Ale";

                        XmlElement yeast_version = documentRecipe.CreateElement("VERSION");
                        yeast_version.InnerText = "1";

                        XmlElement yeast_type = documentRecipe.CreateElement("TYPE");
                        yeast_type.InnerText = "Ale";

                        XmlElement yeast_form = documentRecipe.CreateElement("FORM");
                        yeast_form.InnerText = "Liquid";

                        XmlElement yeast_amount = documentRecipe.CreateElement("AMOUNT");
                        yeast_amount.InnerText = "0";

                        XmlElement yeast_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        yeast_amount_is_weight.InnerText = "FALSE";

                        XmlElement yeast_laboratory = documentRecipe.CreateElement("LABORATORY");
                        yeast_laboratory.InnerText = "Wyeast Labs";

                        XmlElement yeast_product_id = documentRecipe.CreateElement("PRODUCT_ID");
                        yeast_product_id.InnerText = "1222";

                        XmlElement yeast_min_temperature = documentRecipe.CreateElement("MIN_TEMPERATURE");
                        yeast_min_temperature.InnerText = "0";

                        XmlElement yeast_max_temperature = documentRecipe.CreateElement("MAX_TEMPERATURE");
                        yeast_max_temperature.InnerText = "0";

                        XmlElement yeast_flocculation = documentRecipe.CreateElement("FLOCCULATION");
                        yeast_flocculation.InnerText = "High";

                        XmlElement yeast_attenuation = documentRecipe.CreateElement("ATTENUATION");
                        yeast_attenuation.InnerText = "69";

                        XmlElement yeast_notes = documentRecipe.CreateElement("NOTES");
                        yeast_notes.InnerText = "";

                        XmlElement yeast_best_for = documentRecipe.CreateElement("BEST_FOR");
                        yeast_best_for.InnerText = "";

                        XmlElement yeast_max_reuse = documentRecipe.CreateElement("MAX_REUSE");
                        yeast_max_reuse.InnerText = "5";

                        XmlElement yeast_times_cultured = documentRecipe.CreateElement("TIMES_CULTURED");
                        yeast_times_cultured.InnerText = "0";

                        XmlElement yeast_add_to_secondary = documentRecipe.CreateElement("ADD_TO_SECONDARY");
                        yeast_add_to_secondary.InnerText = "FALSE";

                        XmlElement yeast_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        yeast_display_amount.InnerText = "35 ml";

                        XmlElement yeast_disp_min_temp = documentRecipe.CreateElement("DISP_MIN_TEMP");
                        yeast_disp_min_temp.InnerText = "64.9 F";

                        XmlElement yeast_disp_max_temp = documentRecipe.CreateElement("DISP_MAX_TEMP");
                        yeast_disp_max_temp.InnerText = "68.0 F";

                        XmlElement yeast_inventory = documentRecipe.CreateElement("INVENTORY");
                        yeast_inventory.InnerText = "0 Pkgs";

                        XmlElement yeast_culture_date = documentRecipe.CreateElement("CULTURE_DATE");
                        yeast_culture_date.InnerText = "8/31/2014";


                        yeast.AppendChild(yeast_name);
                        yeast.AppendChild(yeast_version);
                        yeast.AppendChild(yeast_type);
                        yeast.AppendChild(yeast_form);
                        yeast.AppendChild(yeast_amount);
                        yeast.AppendChild(yeast_amount_is_weight);
                        yeast.AppendChild(yeast_laboratory);
                        yeast.AppendChild(yeast_product_id);
                        yeast.AppendChild(yeast_min_temperature);
                        yeast.AppendChild(yeast_max_temperature);
                        yeast.AppendChild(yeast_flocculation);
                        yeast.AppendChild(yeast_attenuation);
                        yeast.AppendChild(yeast_notes);
                        yeast.AppendChild(yeast_best_for);
                        yeast.AppendChild(yeast_max_reuse);
                        yeast.AppendChild(yeast_times_cultured);
                        yeast.AppendChild(yeast_add_to_secondary);
                        yeast.AppendChild(yeast_display_amount);
                        yeast.AppendChild(yeast_disp_min_temp);
                        yeast.AppendChild(yeast_disp_max_temp);
                        yeast.AppendChild(yeast_inventory);
                        yeast.AppendChild(yeast_culture_date);

                        yeasts.AppendChild(yeast);
                    }

                    //WATER
                    XmlElement waters = documentRecipe.CreateElement("WATERS");

                    //STYLE
                    if (cbbStyleRecipes.Text == "")
                    {
                        message.title = "Error";
                        message.Content = "Please choose style";
                        message.ShowDialog();
                        return;
                    }
                    XmlElement style = documentRecipe.CreateElement("STYLE");
                    XmlNode style_root = documentStyle.DocumentElement;
                    XmlNode style_node = style_root.SelectSingleNode("descendant::STYLE[NAME='" + cbbStyleRecipes.Text + "']");
                    string style_name_text = "";
                    string style_version_text = "1";
                    string style_category_text = "";
                    string style_category_number_text = "1";
                    string style_style_letter_text = "";
                    string style_style_guide_text = "";
                    string style_type_text = "";
                    string style_og_min_text = "0.000";
                    string style_og_max_text = "0.000";
                    string style_fg_min_text = "0.000";
                    string style_fg_max_text = "0.000";
                    string style_ibu_min_text = "0.000";
                    string style_ibu_max_text = "0.000";
                    string style_color_min_text = "0.000";
                    string style_color_max_text = "0.000";
                    string style_carb_min_text = "0.000";
                    string style_carb_max_text = "0.000";
                    string style_abv_max_text = "0.000";
                    string style_abv_min_text = "0.000";
                    string style_notes_text = "";
                    string style_profile_text = "";
                    string style_ingredients_text = "";
                    string style_examples_text = "";
                    string style_display_og_min_text = "";
                    string style_display_og_max_text = "";
                    string style_display_fg_min_text = "";
                    string style_display_fg_max_text = "";
                    string style_display_color_min_text = "";
                    string style_display_color_max_text = "";
                    string style_og_range_text = "";
                    string style_fg_range_text = "";
                    string style_ibu_range_text = "";
                    string style_carb_range_text = "";
                    string style_color_range_text = "";
                    string style_abv_range_text = "";
                    if (style_node != null)
                    {
                        foreach (XmlNode nodes in style_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        style_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        style_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY":
                                    {
                                        style_category_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY_NUMBER":
                                    {
                                        style_category_number_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_LETTER":
                                    {
                                        style_style_letter_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_GUIDE":
                                    {
                                        style_style_guide_text = nodes.InnerText;
                                        break;
                                    }
                                case "TYPE":
                                    {
                                        style_type_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MIN":
                                    {
                                        style_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MAX":
                                    {
                                        style_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MIN":
                                    {
                                        style_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MAX":
                                    {
                                        style_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MIN":
                                    {
                                        style_ibu_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MAX":
                                    {
                                        style_ibu_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MIN":
                                    {
                                        style_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MAX":
                                    {
                                        style_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MIN":
                                    {
                                        style_carb_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MAX":
                                    {
                                        style_carb_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MAX":
                                    {
                                        style_abv_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MIN":
                                    {
                                        style_abv_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        style_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "PROFILE":
                                    {
                                        style_profile_text = nodes.InnerText;
                                        break;
                                    }
                                case "INGREDIENTS":
                                    {
                                        style_ingredients_text = nodes.InnerText;
                                        break;
                                    }
                                case "EXAMPLES":
                                    {
                                        style_examples_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MIN":
                                    {
                                        style_display_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MAX":
                                    {
                                        style_display_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MIN":
                                    {
                                        style_display_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MAX":
                                    {
                                        style_display_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MIN":
                                    {
                                        style_display_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MAX":
                                    {
                                        style_display_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_RANGE":
                                    {
                                        style_og_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_RANGE":
                                    {
                                        style_fg_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_RANGE":
                                    {
                                        style_ibu_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_RANGE":
                                    {
                                        style_carb_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_RANGE":
                                    {
                                        style_color_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_RANGE":
                                    {
                                        style_abv_range_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }
                        
                    }
                    XmlElement style_name = documentRecipe.CreateElement("NAME");
                    style_name.InnerText = style_name_text;

                    XmlElement style_version = documentRecipe.CreateElement("VERSION");
                    style_version.InnerText = style_version_text;

                    XmlElement style_category = documentRecipe.CreateElement("CATEGORY");
                    style_category.InnerText = style_category_text;

                    XmlElement style_category_number = documentRecipe.CreateElement("CATEGORY_NUMBER");
                    style_category_number.InnerText = style_category_number_text;

                    XmlElement style_style_letter = documentRecipe.CreateElement("STYLE_LETTER");
                    style_style_letter.InnerText = style_style_letter_text;

                    XmlElement style_style_guide = documentRecipe.CreateElement("STYLE_GUIDE");
                    style_style_guide.InnerText = style_style_guide_text;

                    XmlElement style_type = documentRecipe.CreateElement("TYPE");
                    style_type.InnerText = style_type_text;

                    XmlElement style_og_min = documentRecipe.CreateElement("OG_MIN");
                    style_og_min.InnerText = style_og_min_text;

                    XmlElement style_og_max = documentRecipe.CreateElement("OG_MAX");
                    style_og_max.InnerText = style_og_max_text;

                    XmlElement style_fg_min = documentRecipe.CreateElement("FG_MIN");
                    style_fg_min.InnerText = style_fg_min_text;

                    XmlElement style_fg_max = documentRecipe.CreateElement("FG_MAX");
                    style_fg_max.InnerText = style_fg_max_text;

                    XmlElement style_ibu_min = documentRecipe.CreateElement("IBU_MIN");
                    style_ibu_min.InnerText = style_ibu_min_text;

                    XmlElement style_ibu_max = documentRecipe.CreateElement("IBU_MAX");
                    style_ibu_max.InnerText = style_ibu_max_text;

                    XmlElement style_color_min = documentRecipe.CreateElement("COLOR_MIN");
                    style_color_min.InnerText = style_color_min_text;

                    XmlElement style_color_max = documentRecipe.CreateElement("COLOR_MAX");
                    style_color_max.InnerText = style_color_max_text;

                    XmlElement style_carb_min = documentRecipe.CreateElement("CARB_MIN");
                    style_carb_min.InnerText = style_carb_min_text;

                    XmlElement style_carb_max = documentRecipe.CreateElement("CARB_MAX");
                    style_carb_max.InnerText = style_carb_max_text;

                    XmlElement style_abv_max = documentRecipe.CreateElement("ABV_MAX");
                    style_abv_max.InnerText = style_abv_max_text;

                    XmlElement style_abv_min = documentRecipe.CreateElement("ABV_MIN");
                    style_abv_min.InnerText = style_abv_min_text;

                    XmlElement style_notes = documentRecipe.CreateElement("NOTES");
                    style_notes.InnerText = style_notes_text;

                    XmlElement style_profile = documentRecipe.CreateElement("PROFILE");
                    style_profile.InnerText = style_profile_text;

                    XmlElement style_ingredients = documentRecipe.CreateElement("INGREDIENTS");
                    style_ingredients.InnerText = style_ingredients_text;

                    XmlElement style_examples = documentRecipe.CreateElement("EXAMPLES");
                    style_examples.InnerText = style_examples_text;

                    XmlElement style_display_og_min = documentRecipe.CreateElement("DISPLAY_OG_MIN");
                    style_display_og_min.InnerText = style_display_og_min_text;

                    XmlElement style_display_og_max = documentRecipe.CreateElement("DISPLAY_OG_MAX");
                    style_display_og_max.InnerText = style_display_og_max_text;

                    XmlElement style_display_fg_min = documentRecipe.CreateElement("DISPLAY_FG_MIN");
                    style_display_fg_min.InnerText = style_display_fg_min_text;

                    XmlElement style_display_fg_max = documentRecipe.CreateElement("DISPLAY_FG_MAX");
                    style_display_fg_max.InnerText = style_display_fg_max_text;

                    XmlElement style_display_color_min = documentRecipe.CreateElement("DISPLAY_COLOR_MIN");
                    style_display_color_min.InnerText = style_display_color_min_text;

                    XmlElement style_display_color_max = documentRecipe.CreateElement("DISPLAY_COLOR_MAX");
                    style_display_color_max.InnerText = style_display_color_max_text;

                    XmlElement style_og_range = documentRecipe.CreateElement("OG_RANGE");
                    style_og_range.InnerText = style_og_range_text;

                    XmlElement style_fg_range = documentRecipe.CreateElement("FG_RANGE");
                    style_fg_range.InnerText = style_fg_range_text;

                    XmlElement style_ibu_range = documentRecipe.CreateElement("IBU_RANGE");
                    style_ibu_range.InnerText = style_ibu_range_text;

                    XmlElement style_carb_range = documentRecipe.CreateElement("CARB_RANGE");
                    style_carb_range.InnerText = style_carb_range_text;

                    XmlElement style_color_range = documentRecipe.CreateElement("COLOR_RANGE");
                    style_color_range.InnerText = style_color_range_text;

                    XmlElement style_abv_range = documentRecipe.CreateElement("ABV_RANGE");
                    style_abv_range.InnerText = style_abv_range_text;

                    style.AppendChild(style_name);
                    style.AppendChild(style_version);
                    style.AppendChild(style_category);
                    style.AppendChild(style_category_number);
                    style.AppendChild(style_style_letter);
                    style.AppendChild(style_style_guide);
                    style.AppendChild(style_type);
                    style.AppendChild(style_og_min);
                    style.AppendChild(style_og_max);
                    style.AppendChild(style_fg_min);
                    style.AppendChild(style_fg_max);
                    style.AppendChild(style_ibu_min);
                    style.AppendChild(style_ibu_max);
                    style.AppendChild(style_color_min);
                    style.AppendChild(style_color_max);
                    style.AppendChild(style_carb_min);
                    style.AppendChild(style_carb_max);
                    style.AppendChild(style_abv_max);
                    style.AppendChild(style_abv_min);
                    style.AppendChild(style_notes);
                    style.AppendChild(style_profile);
                    style.AppendChild(style_ingredients);
                    style.AppendChild(style_examples);
                    style.AppendChild(style_display_og_min);
                    style.AppendChild(style_display_og_max);
                    style.AppendChild(style_display_fg_min);
                    style.AppendChild(style_display_fg_max);
                    style.AppendChild(style_display_color_min);
                    style.AppendChild(style_display_color_max);
                    style.AppendChild(style_og_range);
                    style.AppendChild(style_fg_range);
                    style.AppendChild(style_ibu_range);
                    style.AppendChild(style_carb_range);
                    style.AppendChild(style_color_range);
                    style.AppendChild(style_abv_range);
                    

                    //EQUIPMENT
                    if (cbbEquipmentRecipes.Text == "")
                    {
                        message.title = "Error";
                        message.Content = "Please choose equipment";
                        message.ShowDialog();
                        return;
                    }
                    XmlElement equipment = documentRecipe.CreateElement("EQUIPMENT");
                    XmlNode equipment_root = documentEquipment.DocumentElement;
                    XmlNode equipment_node = equipment_root.SelectSingleNode("descendant::EQUIPMENT[NAME='" + cbbEquipmentRecipes.Text + "']");
                    string equipment_name_text = "";
                    string equipment_version_text = "1";
                    string equipment_boil_size_text = "0.000";
                    string equipment_batch_size_text = "0.000";
                    string equipment_tun_volume_text = "0.000";
                    string equipment_tun_weight_text = "0.000";
                    string equipment_tun_specific_heat_text = "0.000";
                    string equipment_top_up_water_text = "0.000";
                    string equipment_trub_chiller_loss_text = "0.000";
                    string equipment_evap_rate_text = "0.000";
                    string equipment_boil_time_text = "0.000";
                    string equipment_calc_boil_volume_text = "FALSE";
                    string equipment_lauter_deadspace_text = "0.000";
                    string equipment_top_up_kettle_text = "0.000";
                    string equipment_hop_utilization_text = "0.000";
                    string equipment_notes_text = "";
                    string equipment_display_boil_size_text = "";
                    string equipment_display_batch_size_text = "";
                    string equipment_display_tun_volume_text = "";
                    string equipment_display_tun_weight_text = "";
                    string equipment_display_top_up_water_text = "";
                    string equipment_display_trub_chiller_loss_text = "";
                    string equipment_display_lauter_deadspace_text = "";
                    string equipment_display_top_up_kettle_text = "";
                   
                    if (equipment_node != null)
                    {
                        foreach (XmlNode nodes in equipment_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        equipment_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        equipment_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_SIZE":
                                    {
                                        equipment_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "BATCH_SIZE":
                                    {
                                        equipment_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_VOLUME":
                                    {
                                        equipment_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_WEIGHT":
                                    {
                                        equipment_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_SPECIFIC_HEAT":
                                    {
                                        equipment_tun_specific_heat_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_WATER":
                                    {
                                        equipment_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "TRUB_CHILLER_LOSS":
                                    {
                                        equipment_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "EVAP_RATE":
                                    {
                                        equipment_evap_rate_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_TIME":
                                    {
                                        equipment_boil_time_text = nodes.InnerText;
                                        break;
                                    }
                                case "CALC_BOIL_VOLUME":
                                    {
                                        equipment_calc_boil_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "LAUTER_DEADSPACE":
                                    {
                                        equipment_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_KETTLE":
                                    {
                                        equipment_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                                case "HOP_UTILIZATION":
                                    {
                                        equipment_hop_utilization_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        equipment_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BOIL_SIZE":
                                    {
                                        equipment_display_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BATCH_SIZE":
                                    {
                                        equipment_display_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_VOLUME":
                                    {
                                        equipment_display_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_WEIGHT":
                                    {
                                        equipment_display_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_WATER":
                                    {
                                        equipment_display_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TRUB_CHILLER_LOSS":
                                    {
                                        equipment_display_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_LAUTER_DEADSPACE":
                                    {
                                        equipment_display_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_KETTLE":
                                    {
                                        equipment_display_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }
                    }
                    XmlElement equipment_name = documentRecipe.CreateElement("NAME");
                    equipment_name.InnerText = equipment_name_text;

                    XmlElement equipment_version = documentRecipe.CreateElement("VERSION");
                    equipment_version.InnerText = equipment_version_text;

                    XmlElement equipment_boil_size = documentRecipe.CreateElement("BOIL_SIZE");
                    equipment_boil_size.InnerText = equipment_boil_size_text;

                    XmlElement equipment_batch_size = documentRecipe.CreateElement("BATCH_SIZE");
                    equipment_batch_size.InnerText = equipment_batch_size_text;

                    XmlElement equipment_tun_volume = documentRecipe.CreateElement("TUN_VOLUME");
                    equipment_tun_volume.InnerText = equipment_tun_volume_text;

                    XmlElement equipment_tun_weight = documentRecipe.CreateElement("TUN_WEIGHT");
                    equipment_tun_weight.InnerText = equipment_tun_weight_text;

                    XmlElement equipment_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    equipment_tun_specific_heat.InnerText = equipment_tun_specific_heat_text;

                    XmlElement equipment_top_up_water = documentRecipe.CreateElement("TOP_UP_WATER");
                    equipment_top_up_water.InnerText = equipment_top_up_water_text;

                    XmlElement equipment_trub_chiller_loss = documentRecipe.CreateElement("TRUB_CHILLER_LOSS");
                    equipment_trub_chiller_loss.InnerText = equipment_trub_chiller_loss_text;

                    XmlElement equipment_evap_rate = documentRecipe.CreateElement("EVAP_RATE");
                    equipment_evap_rate.InnerText = equipment_evap_rate_text;

                    XmlElement equipment_boil_time = documentRecipe.CreateElement("BOIL_TIME");
                    equipment_boil_time.InnerText = equipment_boil_time_text;

                    XmlElement equipment_calc_boil_volume = documentRecipe.CreateElement("CALC_BOIL_VOLUME");
                    equipment_calc_boil_volume.InnerText = equipment_calc_boil_volume_text;

                    XmlElement equipment_lauter_deadspace = documentRecipe.CreateElement("LAUTER_DEADSPACE");
                    equipment_lauter_deadspace.InnerText = equipment_lauter_deadspace_text;

                    XmlElement equipment_top_up_kettle = documentRecipe.CreateElement("TOP_UP_KETTLE");
                    equipment_top_up_kettle.InnerText = equipment_top_up_kettle_text;

                    XmlElement equipment_hop_utilization = documentRecipe.CreateElement("HOP_UTILIZATION");
                    equipment_hop_utilization.InnerText = equipment_hop_utilization_text;

                    XmlElement equipment_notes = documentRecipe.CreateElement("NOTES");
                    equipment_notes.InnerText = equipment_notes_text;

                    XmlElement equipment_display_boil_size = documentRecipe.CreateElement("DISPLAY_BOIL_SIZE");
                    equipment_display_boil_size.InnerText = equipment_display_boil_size_text;

                    XmlElement equipment_display_batch_size = documentRecipe.CreateElement("DISPLAY_BATCH_SIZE");
                    equipment_display_batch_size.InnerText = equipment_display_batch_size_text;

                    XmlElement equipment_display_tun_volume = documentRecipe.CreateElement("DISPLAY_TUN_VOLUME");
                    equipment_display_tun_volume.InnerText = equipment_display_tun_volume_text;

                    XmlElement equipment_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    equipment_display_tun_weight.InnerText = equipment_display_tun_weight_text;

                    XmlElement equipment_display_top_up_water = documentRecipe.CreateElement("DISPLAY_TOP_UP_WATER");
                    equipment_display_top_up_water.InnerText = equipment_display_top_up_water_text;

                    XmlElement equipment_display_trub_chiller_loss = documentRecipe.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    equipment_display_trub_chiller_loss.InnerText = equipment_display_trub_chiller_loss_text;

                    XmlElement equipment_display_lauter_deadspace = documentRecipe.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    equipment_display_lauter_deadspace.InnerText = equipment_display_lauter_deadspace_text;

                    XmlElement equipment_display_top_up_kettle = documentRecipe.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    equipment_display_top_up_kettle.InnerText = equipment_display_top_up_kettle_text;

                    equipment.AppendChild(equipment_name);
                    equipment.AppendChild(equipment_version);
                    equipment.AppendChild(equipment_boil_size);
                    equipment.AppendChild(equipment_batch_size);
                    equipment.AppendChild(equipment_tun_volume);
                    equipment.AppendChild(equipment_tun_weight);
                    equipment.AppendChild(equipment_tun_specific_heat);
                    equipment.AppendChild(equipment_top_up_water);
                    equipment.AppendChild(equipment_trub_chiller_loss);
                    equipment.AppendChild(equipment_evap_rate);
                    equipment.AppendChild(equipment_boil_time);
                    equipment.AppendChild(equipment_calc_boil_volume);
                    equipment.AppendChild(equipment_lauter_deadspace);
                    equipment.AppendChild(equipment_top_up_kettle);
                    equipment.AppendChild(equipment_hop_utilization);
                    equipment.AppendChild(equipment_notes);
                    equipment.AppendChild(equipment_display_boil_size);
                    equipment.AppendChild(equipment_display_batch_size);
                    equipment.AppendChild(equipment_display_tun_volume);
                    equipment.AppendChild(equipment_display_tun_weight);
                    equipment.AppendChild(equipment_display_top_up_water);
                    equipment.AppendChild(equipment_display_trub_chiller_loss);
                    equipment.AppendChild(equipment_display_lauter_deadspace);
                    equipment.AppendChild(equipment_display_top_up_kettle);


                    //MASH
                    XmlElement mash = documentRecipe.CreateElement("MASH");

                    XmlElement mash_name = documentRecipe.CreateElement("NAME");
                    mash_name.InnerText = "Single Infusion";

                    XmlElement mash_version = documentRecipe.CreateElement("VERSION");
                    mash_version.InnerText = "1";

                    XmlElement mash_grain_temp = documentRecipe.CreateElement("GRAIN_TEMP");
                    mash_grain_temp.InnerText = "22.22222200";

                    XmlElement mash_tun_temp = documentRecipe.CreateElement("TUN_TEMP");
                    mash_tun_temp.InnerText = "22.22222200";

                    XmlElement mash_sparge_temp = documentRecipe.CreateElement("SPARGE_TEMP");
                    mash_sparge_temp.InnerText = "75.55555600";

                    XmlElement mash_ph = documentRecipe.CreateElement("PH");
                    mash_ph.InnerText = "5.4";

                    XmlElement mash_tun_weigth = documentRecipe.CreateElement("TUN_WEIGHT");
                    mash_tun_weigth.InnerText = "1.81436800";

                    XmlElement mash_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    mash_tun_specific_heat.InnerText = "0.30000000";

                    XmlElement mash_equip_adjust = documentRecipe.CreateElement("EQUIP_ADJUST");
                    mash_equip_adjust.InnerText = "FALSE";

                    XmlElement mash_notes = documentRecipe.CreateElement("NOTES");
                    mash_notes.InnerText = "";

                    XmlElement mash_display_grain_temp = documentRecipe.CreateElement("DISPLAY_GRAIN_TEMP");
                    mash_display_grain_temp.InnerText = "72.0 F";

                    XmlElement mash_display_tun_temp = documentRecipe.CreateElement("DISPLAY_TUN_TEMP");
                    mash_display_tun_temp.InnerText = "72.0";

                    XmlElement mash_display_sparge_temp = documentRecipe.CreateElement("DISPLAY_SPARGE_TEMP");
                    mash_display_sparge_temp.InnerText = "168.0 F";

                    XmlElement mash_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    mash_display_tun_weight.InnerText = "4.00 lb";

                    XmlElement mash_mash_steps = documentRecipe.CreateElement("MASH_STEPS");

                    if (tableViewMashRecipes.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableViewMashRecipes.DataRowCount; i++)
                        {
                            XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                            mash_step_name.InnerText = tableViewMashRecipes.GetRowCellValue(i, "name").ToString();

                            XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                            mash_step_version.InnerText = "1";

                            XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                            mash_step_type.InnerText = tableViewMashRecipes.GetRowCellValue(i, "type").ToString();

                            XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_amount").ToString();

                            XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_time").ToString();

                            XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_temp").ToString();

                            XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "ramp_time").ToString();

                            XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "end_temp").ToString();

                            XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = tableViewMashRecipes.GetRowCellValue(i, "description").ToString();

                            XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = tableViewMashRecipes.GetRowCellValue(i, "water_grain_ratio").ToString();

                            XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "decoction_amt").ToString();

                            XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_temp").ToString();

                            XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_step_temp").ToString();

                            XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_infuse_amt").ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            mash_mash_steps.AppendChild(mash_step);
                        }
                    }
                    else
                    {
                        XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                        mash_step_name.InnerText = "Mash Out";

                        XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                        mash_step_version.InnerText = "1";

                        XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                        mash_step_type.InnerText = "Infusion";

                        XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = "6.81378";

                        XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = "10";

                        XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = "0";

                        XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = "2";

                        XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = "75.55556";

                        XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = "";

                        XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = "2.05";

                        XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = "0.00 qt";

                        XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = "185.9 F";

                        XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = "";

                        XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = "7.20 qt";


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_mash_steps.AppendChild(mash_step);
                    }
                    mash.AppendChild(mash_name);
                    mash.AppendChild(mash_version);
                    mash.AppendChild(mash_grain_temp);
                    mash.AppendChild(mash_tun_temp);
                    mash.AppendChild(mash_sparge_temp);
                    mash.AppendChild(mash_ph);
                    mash.AppendChild(mash_tun_weigth);
                    mash.AppendChild(mash_tun_specific_heat);
                    mash.AppendChild(mash_equip_adjust);
                    mash.AppendChild(mash_notes);
                    mash.AppendChild(mash_display_grain_temp);
                    mash.AppendChild(mash_display_tun_temp);
                    mash.AppendChild(mash_display_sparge_temp);
                    mash.AppendChild(mash_display_tun_weight);
                    mash.AppendChild(mash_mash_steps);

                    XmlElement notes = documentRecipe.CreateElement("NOTES");
                    notes.InnerText = txtNotesRecipes.Text;

                    XmlElement taste_notes = documentRecipe.CreateElement("TASTE_NOTES");
                    taste_notes.InnerText = txtTasteNotesRecipes.Text;

                    XmlElement taste_rating = documentRecipe.CreateElement("TASTE_RATING");
                    taste_rating.InnerText = txtTasteRatingRecipes.Text;

                    XmlElement og = documentRecipe.CreateElement("OG");
                    og.InnerText = lbOGRecipes.Text;

                    XmlElement fg = documentRecipe.CreateElement("FG");
                    fg.InnerText = lbFGRecipes.Text;

                    XmlElement carbonation = documentRecipe.CreateElement("CARBONATION");
                    carbonation.InnerText = txtCarbonationVolumesRecipes.Text;

                    XmlElement fermentation_stages = documentRecipe.CreateElement("FERMENTATION_STAGES");
                    fermentation_stages.InnerText = "2";

                    XmlElement primary_age = documentRecipe.CreateElement("PRIMARY_AGE");
                    primary_age.InnerText = txtPrimaryAgeRecipes.Text.Replace("s","");

                    XmlElement primary_temp = documentRecipe.CreateElement("PRIMARY_TEMP");
                    primary_temp.InnerText = txtPrimaryTempRecipes.Text.Replace("C","");

                    XmlElement secondary_age = documentRecipe.CreateElement("SECONDARY_AGE");
                    secondary_age.InnerText = txtSecondaryAgeRecipes.Text.Replace("s", "");

                    XmlElement secondary_temp = documentRecipe.CreateElement("SECONDARY_TEMP");
                    secondary_temp.InnerText = txtSecondaryTempRecipes.Text.Replace("C", "");

                    XmlElement tertiary_age = documentRecipe.CreateElement("TERTIARY_AGE");
                    tertiary_age.InnerText = txtTertiaryAgeRecipes.Text.Replace("s", "");

                    XmlElement age = documentRecipe.CreateElement("AGE");
                    age.InnerText = "14.0";

                    XmlElement age_temp = documentRecipe.CreateElement("AGE_TEMP");
                    age_temp.InnerText = "11.111";

                    XmlElement carbonation_used = documentRecipe.CreateElement("CARBONATION_USED");
                    carbonation_used.InnerText = "12 PSI";

                    XmlElement date = documentRecipe.CreateElement("DATE");
                    date.InnerText = cbbdateDateFirstBrewedRecipes.Text;

                    XmlElement est_og = documentRecipe.CreateElement("EST_OG");
                    est_og.InnerText = lbOGRecipes.Text;

                    XmlElement est_fg = documentRecipe.CreateElement("EST_FG");
                    est_fg.InnerText = lbFGRecipes.Text;

                    XmlElement est_color = documentRecipe.CreateElement("EST_COLOR");
                    est_color.InnerText = lbColorRecipes.Text;

                    XmlElement ibu = documentRecipe.CreateElement("IBU");
                    ibu.InnerText = lbIBURecipes.Text;

                    XmlElement ibu_method = documentRecipe.CreateElement("IBU_METHOD");
                    ibu_method.InnerText = "Tinseth";

                    XmlElement est_abv = documentRecipe.CreateElement("EST_ABV");
                    est_abv.InnerText = lbABVRecipes.Text;

                    XmlElement abv = documentRecipe.CreateElement("ABV");
                    abv.InnerText = "5.1 %";

                    XmlElement actual_efficiency = documentRecipe.CreateElement("ACTUAL_EFFICIENCY");
                    actual_efficiency.InnerText = "69.7 %";

                    XmlElement calories = documentRecipe.CreateElement("CALORIES");
                    calories.InnerText = "242 cal/pint";

                    XmlElement display_batch_size = documentRecipe.CreateElement("DISPLAY_BATCH_SIZE");
                    display_batch_size.InnerText = "5.00 gal";

                    XmlElement display_boil_size = documentRecipe.CreateElement("DISPLAY_BOIL_SIZE");
                    display_boil_size.InnerText = "5.50 gal";

                    XmlElement display_og = documentRecipe.CreateElement("DISPLAY_OG");
                    display_og.InnerText = "1.054 SG";

                    XmlElement display_fg = documentRecipe.CreateElement("DISPLAY_FG");
                    display_fg.InnerText = "1.015 SG";

                    XmlElement display_primary_temp = documentRecipe.CreateElement("DISPLAY_PRIMARY_TEMP");
                    display_primary_temp.InnerText = "68.0 F";

                    XmlElement display_secondary_temp = documentRecipe.CreateElement("DISPLAY_SECONDARY_TEMP");
                    display_secondary_temp.InnerText = "68.0 F";

                    XmlElement display_tertiary_temp = documentRecipe.CreateElement("DISPLAY_TERTIARY_TEMP");
                    display_tertiary_temp.InnerText = "68.0 F";

                    XmlElement display_age_temp = documentRecipe.CreateElement("DISPLAY_AGE_TEMP");
                    display_age_temp.InnerText = "52.0 F";

                    recipe.AppendChild(name);
                    recipe.AppendChild(version);
                    recipe.AppendChild(type);
                    recipe.AppendChild(brewer);
                    recipe.AppendChild(asst_brewer);
                    recipe.AppendChild(batch_size);
                    recipe.AppendChild(boil_size);
                    recipe.AppendChild(boil_time);
                    recipe.AppendChild(efficiency);
                    recipe.AppendChild(hops);
                    recipe.AppendChild(fermentables);
                    recipe.AppendChild(miscs);
                    recipe.AppendChild(yeasts);
                    recipe.AppendChild(waters);
                    recipe.AppendChild(style);
                    recipe.AppendChild(equipment);
                    recipe.AppendChild(mash);
                    recipe.AppendChild(notes);
                    recipe.AppendChild(taste_notes);
                    recipe.AppendChild(taste_rating);
                    recipe.AppendChild(og);
                    recipe.AppendChild(fg);
                    recipe.AppendChild(carbonation);
                    recipe.AppendChild(fermentation_stages);
                    recipe.AppendChild(primary_age);
                    recipe.AppendChild(primary_temp);
                    recipe.AppendChild(secondary_age);
                    recipe.AppendChild(secondary_temp);
                    recipe.AppendChild(tertiary_age);
                    recipe.AppendChild(age);
                    recipe.AppendChild(age_temp);
                    recipe.AppendChild(carbonation_used);
                    recipe.AppendChild(date);
                    recipe.AppendChild(est_og);
                    recipe.AppendChild(est_fg);
                    recipe.AppendChild(est_color);
                    recipe.AppendChild(ibu);
                    recipe.AppendChild(ibu_method);
                    recipe.AppendChild(est_abv);
                    recipe.AppendChild(abv);
                    recipe.AppendChild(actual_efficiency);
                    recipe.AppendChild(calories);
                    recipe.AppendChild(display_batch_size);
                    recipe.AppendChild(display_boil_size);
                    recipe.AppendChild(display_og);
                    recipe.AppendChild(display_fg);
                    recipe.AppendChild(display_primary_temp);
                    recipe.AppendChild(display_secondary_temp);
                    recipe.AppendChild(display_tertiary_temp);
                    recipe.AppendChild(display_age_temp);

                    documentRecipe.DocumentElement.InsertAfter(recipe, documentRecipe.DocumentElement.LastChild);
                    try
                    {
                        fsRecipes = new FileStream(fileRecipes, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentRecipe.Save(fsRecipes);
                    fsRecipes.Close();
                    message.title = "Save Recipe";
                    message.Content = "Save success";
                    message.ShowDialog();
                }
                loadRecipes();
            }
        }

        private void tableRecipes_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtRecipes.Text = tableViewRecipes.GetFocusedDataRow()["name"].ToString();
                Styles style = (Styles)tableViewRecipes.GetFocusedDataRow()["style"];
                cbbStyleRecipes.Text = style.getNAME();
                Equipments equipment = (Equipments)tableViewRecipes.GetFocusedDataRow()["equipment"];
                cbbEquipmentRecipes.Text = equipment.getNAME();
                txtBrewerRecipes.Text = tableViewRecipes.GetFocusedDataRow()["brewer"].ToString();
                txtAsstBrewerRecipes.Text = tableViewRecipes.GetFocusedDataRow()["asst_brewer"].ToString();
                txtTargetBatchSizeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["batch_size"].ToString();
                txtTargetBoilSizeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["boil_size"].ToString();
                txtEfficiencyRecipes.Text = tableViewRecipes.GetFocusedDataRow()["efficiency"].ToString();
                txtBoilTimeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["boil_time"].ToString();
                lbOGRecipes.Text = float.Parse(tableViewRecipes.GetFocusedDataRow()["og"].ToString()).ToString();
                lbFGRecipes.Text = float.Parse(tableViewRecipes.GetFocusedDataRow()["fg"].ToString()).ToString();
                lbABVRecipes.Text = tableViewRecipes.GetFocusedDataRow()["abv"].ToString();
                lbIBURecipes.Text = tableViewRecipes.GetFocusedDataRow()["ibu"].ToString();
                //lbColorRecipes.Text = tableViewRecipes.GetFocusedDataRow()["est_color"].ToString();
                txtTasteRatingRecipes.Text = tableViewRecipes.GetFocusedDataRow()["taste_rating"].ToString();
                txtPrimaryAgeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["primary_age"].ToString() + " s";
                txtPrimaryTempRecipes.Text = tableViewRecipes.GetFocusedDataRow()["primary_temp"].ToString() + " C";
                txtSecondaryAgeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["secondary_age"].ToString() + " s";
                txtSecondaryTempRecipes.Text = tableViewRecipes.GetFocusedDataRow()["secondary_temp"].ToString() + " C";
                txtTertiaryAgeRecipes.Text = tableViewRecipes.GetFocusedDataRow()["tertiary_age"].ToString() + " s";
                txtTertiaryTempRecipes.Text = tableViewRecipes.GetFocusedDataRow()["display_tertiary_temp"].ToString() + " C";
                cbbdateDateFirstBrewedRecipes.Text = tableViewRecipes.GetFocusedDataRow()["date"].ToString();
                txtCarbonationVolumesRecipes.Text = tableViewRecipes.GetFocusedDataRow()["carbonation"].ToString();
                txtTasteNotesRecipes.Text = tableViewRecipes.GetFocusedDataRow()["taste_notes"].ToString();
                txtNotesRecipes.Text = tableViewRecipes.GetFocusedDataRow()["notes"].ToString();

                listFermentables listFermentables = (listFermentables)tableViewRecipes.GetFocusedDataRow()["fermentables"];
                List<Fermentables> Fermentables = new List<Fermentables>();
                Fermentables = listFermentables.getFERMENTABLES();
                tableViewFermentablesRecipes.GridControl.DataSource = ul.dataTableFermentables(Fermentables);
                float batch_size = float.Parse(tableViewRecipes.GetFocusedDataRow()["batch_size"].ToString());
                float total = 0;
                float srm = 0;
                float x1 = 1.49F;
                float x2 = 0.69F;
                for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
                {
                    float mcu = 1;
                    string amount_display = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();
                    float amount = float.Parse(amount_display.Replace("lb", ""));
                    float color_display = float.Parse(tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString());
                    mcu = (amount * color_display) / batch_size;
                    total = total + mcu;
                    
                }
                srm = x1 * (total * x2);
                lbColorRecipes.Text = srm + " SRM";

                listHops listHops = (listHops)tableViewRecipes.GetFocusedDataRow()["hops"];
                List<Hops> Hops = new List<Hops>();
                Hops = listHops.getHOPS();
                tableViewHopsRecipes.GridControl.DataSource = ul.dataTableHops(Hops);

                listMiscs listMiscs = (listMiscs)tableViewRecipes.GetFocusedDataRow()["miscs"];
                List<Miscs> Miscs = new List<Miscs>();
                Miscs = listMiscs.getMISCS();
                tableViewMiscRecipes.GridControl.DataSource = ul.dataTableMiscs(Miscs);

                listYeasts listYeasts = (listYeasts)tableViewRecipes.GetFocusedDataRow()["yeasts"];
                List<Yeast> Yeast = new List<Yeast>();
                Yeast = listYeasts.getYEASTS();
                cbbYeastRecipes.DataSource = ul.dataTableYeasts(ul.ListYeasts(documentYeast));
                tableViewYeastRecipes.GridControl.DataSource = ul.dataTableYeasts(Yeast);

                Mashs mashs = (Mashs)tableViewRecipes.GetFocusedDataRow()["mash"];
                listMashStep listMash_step = new listMashStep();
                List<Mash_step> mash_step = new List<Mash_step>();

                listMash_step = mashs.getMASH_STEPS();
                mash_step = listMash_step.getMASH_STEP();
                tableViewMashRecipes.GridControl.DataSource = ul.dataTableMash_Step(mash_step);

                //Color
                float color = srm;
                if (color >= 0 && color <1)
                {
                    pictureRecipe.Image = Properties.Resources.SRM0;
                }
                else if (color >= 1 && color < 2)
                {
                    pictureRecipe.Image = Properties.Resources.SRM1;
                }
                else if (color >= 2 && color < 3)
                {
                    pictureRecipe.Image = Properties.Resources.SRM2;
                }
                else if (color >= 3 && color < 4)
                {
                    pictureRecipe.Image = Properties.Resources.SRM3;
                }
                else if (color >= 4 && color < 5)
                {
                    pictureRecipe.Image = Properties.Resources.SRM4;
                }
                else if (color >= 5 && color < 6)
                {
                    pictureRecipe.Image = Properties.Resources.SRM5;
                }
                else if (color >= 6 && color < 7)
                {
                    pictureRecipe.Image = Properties.Resources.SRM6;
                }
                else if (color >= 7 && color < 8)
                {
                    pictureRecipe.Image = Properties.Resources.SRM7;
                }
                else if (color >= 8 && color < 9)
                {
                    pictureRecipe.Image = Properties.Resources.SRM8;
                }
                else if (color >= 9 && color < 10)
                {
                    pictureRecipe.Image = Properties.Resources.SRM9;
                }
                else if (color >= 10 && color < 11)
                {
                    pictureRecipe.Image = Properties.Resources.SRM10;
                }
                else if (color >= 11 && color < 12)
                {
                    pictureRecipe.Image = Properties.Resources.SRM11;
                }
                else if (color >= 12 && color < 13)
                {
                    pictureRecipe.Image = Properties.Resources.SRM12;
                }
                else if (color >= 13 && color < 14)
                {
                    pictureRecipe.Image = Properties.Resources.SRM13;
                }
                else if (color >= 14 && color < 15)
                {
                    pictureRecipe.Image = Properties.Resources.SRM14;
                }
                else if (color >= 15 && color < 16)
                {
                    pictureRecipe.Image = Properties.Resources.SRM15;
                }
                else if (color >= 16 && color < 17)
                {
                    pictureRecipe.Image = Properties.Resources.SRM16;
                }
                else if (color >= 17 && color < 18)
                {
                    pictureRecipe.Image = Properties.Resources.SRM17;
                }
                else if (color >= 18 && color < 19)
                {
                    pictureRecipe.Image = Properties.Resources.SRM18;
                }
                else if (color >= 19 && color < 20)
                {
                    pictureRecipe.Image = Properties.Resources.SRM19;
                }
                else if (color >= 20 && color < 21)
                {
                    pictureRecipe.Image = Properties.Resources.SRM20;
                }
                else if (color >= 21 && color < 22)
                {
                    pictureRecipe.Image = Properties.Resources.SRM21;
                }
                else if (color >= 22 && color < 23)
                {
                    pictureRecipe.Image = Properties.Resources.SRM22;
                }
                else if (color >= 23 && color < 24)
                {
                    pictureRecipe.Image = Properties.Resources.SRM23;
                }
                else if (color >= 24 && color < 25)
                {
                    pictureRecipe.Image = Properties.Resources.SRM24;
                }
                else if (color >= 25 && color < 26)
                {
                    pictureRecipe.Image = Properties.Resources.SRM25;
                }
                else if (color >= 26 && color < 27)
                {
                    pictureRecipe.Image = Properties.Resources.SRM26;
                }
                else if (color >= 27 && color < 28)
                {
                    pictureRecipe.Image = Properties.Resources.SRM27;
                }
                else if(color >= 28 && color <29)
                {
                    pictureRecipe.Image = Properties.Resources.SRM28;
                }
                else if (color >= 29 && color < 30)
                {
                    pictureRecipe.Image = Properties.Resources.SRM29;
                }
                else if (color >= 30 && color < 31)
                {
                    pictureRecipe.Image = Properties.Resources.SRM30;
                }
                else if (color >= 31 && color < 32)
                {
                    pictureRecipe.Image = Properties.Resources.SRM31;
                }
                else if (color >= 32 && color < 33)
                {
                    pictureRecipe.Image = Properties.Resources.SRM32;
                }
                else if (color >= 33 && color < 34)
                {
                    pictureRecipe.Image = Properties.Resources.SRM33;
                }
                else if(color >= 34 && color <35)
                {
                    pictureRecipe.Image = Properties.Resources.SRM34;
                }
                else if (color >= 35 && color < 36)
                {
                    pictureRecipe.Image = Properties.Resources.SRM35;
                }
                else if (color >= 36)
                {
                    pictureRecipe.Image = Properties.Resources.SRM36;
                }
               
            }
            catch (Exception) { }
        }

        private void btnDeleteRecipe_Click(object sender, EventArgs e)
        {
            if (txtRecipes.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select Recipe";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentRecipe.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::RECIPE[NAME='" + txtRecipes.Text + "']");
                if (node != null)
                {
                    documentRecipe.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsRecipes = new FileStream(fileRecipes, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentRecipe.Save(fsRecipes);
                message.title = "Delete Recipe";
                message.Content = "Delete success";
                message.ShowDialog();
                loadRecipes();
                fsRecipes.Close();
            }
        }

        private void btnImportRecipes_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Recipes> recipes = new List<Recipes>();
                recipes = ul.ListRecipes(doc);
                for (int i = 0; i < recipes.Count; i++)
                {
                    XmlElement recipe = documentRecipe.CreateElement("RECIPE");

                    XmlElement name = documentRecipe.CreateElement("NAME");
                    name.InnerText = recipes[i].getNAME();

                    XmlElement version = documentRecipe.CreateElement("VERSION");
                    version.InnerText = recipes[i].getVERSION().ToString();

                    XmlElement type = documentRecipe.CreateElement("TYPE");
                    type.InnerText = recipes[i].getTYPE();

                    XmlElement brewer = documentRecipe.CreateElement("BREWER");
                    brewer.InnerText = recipes[i].getBREWER();

                    XmlElement asst_brewer = documentRecipe.CreateElement("ASST_BREWER");
                    asst_brewer.InnerText = recipes[i].getASST_BREWER();

                    XmlElement batch_size = documentRecipe.CreateElement("BATCH_SIZE");
                    batch_size.InnerText = recipes[i].getBATCH_SIZE().ToString();

                    XmlElement boil_size = documentRecipe.CreateElement("BOIL_SIZE");
                    boil_size.InnerText = recipes[i].getBOIL_SIZE().ToString();

                    XmlElement boil_time = documentRecipe.CreateElement("BOIL_TIME");
                    boil_time.InnerText = recipes[i].getBOIL_TIME().ToString();

                    XmlElement efficiency = documentRecipe.CreateElement("EFFICIENCY");
                    efficiency.InnerText = recipes[i].getEFFICIENCY().ToString();

                    //HOPS
                    XmlElement hops = documentRecipe.CreateElement("HOPS");
                    listHops listHops = recipes[i].getHOPS();
                    List<Hops> HOPS = new List<Hops>();
                    HOPS = listHops.getHOPS();
                    for(int j = 0; j< HOPS.Count; j++){

                        XmlElement hop = documentRecipe.CreateElement("HOP");

                        XmlElement hop_name = documentRecipe.CreateElement("NAME");
                        hop_name.InnerText = HOPS[j].getNAME();

                        XmlElement hop_version = documentRecipe.CreateElement("VERSION");
                        hop_version.InnerText = HOPS[j].getVERSION().ToString();

                        XmlElement hop_origin = documentRecipe.CreateElement("ORIGIN");
                        hop_origin.InnerText = HOPS[j].getORIGIN().ToString();

                        XmlElement hop_alpha = documentRecipe.CreateElement("ALPHA");
                        hop_alpha.InnerText = HOPS[j].getALPHA().ToString();

                        XmlElement hop_amount = documentRecipe.CreateElement("AMOUNT");
                        hop_amount.InnerText = HOPS[j].getAMOUNT().ToString();

                        XmlElement hop_use = documentRecipe.CreateElement("USE");
                        hop_use.InnerText = HOPS[j].getUSE().ToString();

                        XmlElement hop_time = documentRecipe.CreateElement("TIME");
                        hop_time.InnerText = HOPS[j].getTIME().ToString();

                        XmlElement hop_notes = documentRecipe.CreateElement("NOTES");
                        hop_notes.InnerText = HOPS[j].getNOTES().ToString();

                        XmlElement hop_type = documentRecipe.CreateElement("TYPE");
                        hop_type.InnerText = HOPS[j].getTYPE().ToString();

                        XmlElement hop_form = documentRecipe.CreateElement("FORM");
                        hop_form.InnerText = HOPS[j].getFORM().ToString();

                        XmlElement hop_beta = documentRecipe.CreateElement("BETA");
                        hop_beta.InnerText = HOPS[j].getBETA().ToString();

                        XmlElement hop_hsi = documentRecipe.CreateElement("HSI");
                        hop_hsi.InnerText = HOPS[j].getHSI().ToString();

                        XmlElement hop_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        hop_display_amount.InnerText = HOPS[j].getDISPLAY_AMOUNT().ToString();

                        XmlElement hop_inventory = documentRecipe.CreateElement("INVENTORY");
                        hop_inventory.InnerText = HOPS[j].getINVENTORY().ToString();

                        XmlElement hop_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        hop_display_time.InnerText = HOPS[j].getDISPLAY_TIME().ToString();

                        hop.AppendChild(hop_name);
                        hop.AppendChild(hop_version);
                        hop.AppendChild(hop_origin);
                        hop.AppendChild(hop_alpha);
                        hop.AppendChild(hop_amount);
                        hop.AppendChild(hop_use);
                        hop.AppendChild(hop_time);
                        hop.AppendChild(hop_notes);
                        hop.AppendChild(hop_type);
                        hop.AppendChild(hop_form);
                        hop.AppendChild(hop_beta);
                        hop.AppendChild(hop_hsi);
                        hop.AppendChild(hop_display_amount);
                        hop.AppendChild(hop_inventory);
                        hop.AppendChild(hop_display_time);

                        hops.AppendChild(hop);

                    }

                    XmlElement fermentables = documentRecipe.CreateElement("FERMENTABLES");
                    listFermentables listFermentable = recipes[i].getFERMENTABLES();
                    List<Fermentables> FERMENTABLES = new List<Fermentables>();
                    FERMENTABLES = listFermentable.getFERMENTABLES();
                    for (int j = 0; j < FERMENTABLES.Count; j++)
                    {
                        XmlElement fermentable = documentRecipe.CreateElement("FERMENTABLE");

                        XmlElement fermentable_name = documentRecipe.CreateElement("NAME");
                        fermentable_name.InnerText = FERMENTABLES[j].getNAME();

                        XmlElement fermentable_version = documentRecipe.CreateElement("VERSION");
                        fermentable_version.InnerText = FERMENTABLES[j].getVERSION().ToString();

                        XmlElement fermentable_type = documentRecipe.CreateElement("TYPE");
                        fermentable_type.InnerText = FERMENTABLES[j].getTYPE().ToString();

                        XmlElement fermentable_amount = documentRecipe.CreateElement("AMOUNT");
                        fermentable_amount.InnerText = FERMENTABLES[j].getAMOUNT().ToString();

                        XmlElement fermentable_yield = documentRecipe.CreateElement("YIELD");
                        fermentable_yield.InnerText = FERMENTABLES[j].getYIELD().ToString();

                        XmlElement fermentable_color = documentRecipe.CreateElement("COLOR");
                        fermentable_color.InnerText = FERMENTABLES[j].getCOLOR().ToString();

                        XmlElement fermentable_add_after_boil = documentRecipe.CreateElement("ADD_AFTER_BOIL");
                        fermentable_add_after_boil.InnerText = FERMENTABLES[j].getADD_AFTER_BOIL().ToString();

                        XmlElement fermentable_origin = documentRecipe.CreateElement("ORIGIN");
                        fermentable_origin.InnerText = FERMENTABLES[j].getORIGIN().ToString();

                        XmlElement fermentable_supplier = documentRecipe.CreateElement("SUPPLIER");
                        fermentable_supplier.InnerText = FERMENTABLES[j].getSUPPLIER().ToString();

                        XmlElement fermentable_notes = documentRecipe.CreateElement("NOTES");
                        fermentable_notes.InnerText = FERMENTABLES[j].getNOTES().ToString();

                        XmlElement fermentable_coarse_fine_diff = documentRecipe.CreateElement("COARSE_FINE_DIFF");
                        fermentable_coarse_fine_diff.InnerText = FERMENTABLES[j].getCOARSE_FINE_DIFF().ToString();

                        XmlElement fermentable_moisture = documentRecipe.CreateElement("MOISTURE");
                        fermentable_moisture.InnerText = FERMENTABLES[j].getMOISTURE().ToString();

                        XmlElement fermentable_diastatic_power = documentRecipe.CreateElement("DIASTATIC_POWER");
                        fermentable_diastatic_power.InnerText = FERMENTABLES[j].getDIASTATIC_POWER().ToString();

                        XmlElement fermentable_protein = documentRecipe.CreateElement("PROTEIN");
                        fermentable_protein.InnerText = FERMENTABLES[j].getPROTEIN().ToString();

                        XmlElement fermentable_max_in_batch = documentRecipe.CreateElement("MAX_IN_BATCH");
                        fermentable_max_in_batch.InnerText = FERMENTABLES[j].getMAX_IN_BATCH().ToString();

                        XmlElement fermentable_recommend_mash = documentRecipe.CreateElement("RECOMMEND_MASH");
                        fermentable_recommend_mash.InnerText = FERMENTABLES[j].getRECOMMEND_MASH().ToString();

                        XmlElement fermentable_ibu_gal_per_lb = documentRecipe.CreateElement("IBU_GAL_PER_LB");
                        fermentable_ibu_gal_per_lb.InnerText = FERMENTABLES[j].getIBU_GAL_PER_LB().ToString();

                        XmlElement fermentable_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        fermentable_display_amount.InnerText = FERMENTABLES[j].getDISPLAY_AMOUNT().ToString();

                        XmlElement fermentable_inventory = documentRecipe.CreateElement("INVENTORY");
                        fermentable_inventory.InnerText = FERMENTABLES[j].getINVENTORY().ToString();

                        XmlElement fermentable_potential = documentRecipe.CreateElement("POTENTIAL");
                        fermentable_potential.InnerText = FERMENTABLES[j].getPOTENTIAL().ToString();

                        XmlElement fermentable_display_color = documentRecipe.CreateElement("DISPLAY_COLOR");
                        fermentable_display_color.InnerText = FERMENTABLES[j].getDISPLAY_COLOR().ToString();


                        fermentable.AppendChild(fermentable_name);
                        fermentable.AppendChild(fermentable_version);
                        fermentable.AppendChild(fermentable_type);
                        fermentable.AppendChild(fermentable_amount);
                        fermentable.AppendChild(fermentable_yield);
                        fermentable.AppendChild(fermentable_color);
                        fermentable.AppendChild(fermentable_add_after_boil);
                        fermentable.AppendChild(fermentable_origin);
                        fermentable.AppendChild(fermentable_supplier);
                        fermentable.AppendChild(fermentable_notes);
                        fermentable.AppendChild(fermentable_coarse_fine_diff);
                        fermentable.AppendChild(fermentable_moisture);
                        fermentable.AppendChild(fermentable_diastatic_power);
                        fermentable.AppendChild(fermentable_protein);
                        fermentable.AppendChild(fermentable_max_in_batch);
                        fermentable.AppendChild(fermentable_recommend_mash);
                        fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                        fermentable.AppendChild(fermentable_display_amount);
                        fermentable.AppendChild(fermentable_inventory);
                        fermentable.AppendChild(fermentable_potential);
                        fermentable.AppendChild(fermentable_display_color);

                        fermentables.AppendChild(fermentable);
                    }


                    XmlElement miscs = documentRecipe.CreateElement("MISCS");
                    listMiscs listMisc = recipes[i].getMISCS();
                    List<Miscs> MISC = new List<Miscs>();
                    MISC = listMisc.getMISCS();
                    if (MISC.Count > 0)
                    {
                        for (int j = 0; j < MISC.Count; j++)
                        {
                            XmlElement misc = documentRecipe.CreateElement("MISC");

                            XmlElement misc_name = documentRecipe.CreateElement("NAME");
                            misc_name.InnerText = MISC[j].getNAME().ToString();

                            XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                            misc_version.InnerText = MISC[j].getVERSION().ToString();

                            XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                            misc_type.InnerText = MISC[j].getTYPE().ToString();

                            XmlElement misc_use = documentRecipe.CreateElement("USE");
                            misc_use.InnerText = MISC[j].getUSE().ToString();

                            XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                            misc_amount.InnerText = MISC[j].getAMOUNT().ToString();

                            XmlElement misc_time = documentRecipe.CreateElement("TIME");
                            misc_time.InnerText = MISC[j].getTIME().ToString();

                            XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                            misc_amount_is_weight.InnerText = MISC[j].getAMOUNT_IS_WEIGHT().ToString();

                            XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                            misc_use_for.InnerText = MISC[j].getUSE_FOR().ToString();

                            XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                            misc_notes.InnerText = MISC[j].getNOTES().ToString();

                            XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                            misc_display_amount.InnerText = MISC[j].getDISPLAY_AMOUNT().ToString();

                            XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                            misc_inventory.InnerText = MISC[j].getINVENTORY().ToString();

                            XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                            misc_display_time.InnerText = MISC[j].getDISPLAY_TIME().ToString();

                            misc.AppendChild(misc_name);
                            misc.AppendChild(misc_version);
                            misc.AppendChild(misc_type);
                            misc.AppendChild(misc_use);
                            misc.AppendChild(misc_amount);
                            misc.AppendChild(misc_time);
                            misc.AppendChild(misc_amount_is_weight);
                            misc.AppendChild(misc_notes);
                            misc.AppendChild(misc_display_amount);
                            misc.AppendChild(misc_inventory);
                            misc.AppendChild(misc_display_time);

                            miscs.AppendChild(misc);
                        }
                    }
                    else
                    {
                        XmlElement misc = documentRecipe.CreateElement("MISC");

                        XmlElement misc_name = documentRecipe.CreateElement("NAME");
                        misc_name.InnerText = "Apricot Extract";

                        XmlElement misc_version = documentRecipe.CreateElement("VERSION");
                        misc_version.InnerText = "1";

                        XmlElement misc_type = documentRecipe.CreateElement("TYPE");
                        misc_type.InnerText = "Flavor";

                        XmlElement misc_use = documentRecipe.CreateElement("USE");
                        misc_use.InnerText = "Bottling";

                        XmlElement misc_amount = documentRecipe.CreateElement("AMOUNT");
                        misc_amount.InnerText = "0.192229";

                        XmlElement misc_time = documentRecipe.CreateElement("TIME");
                        misc_time.InnerText = "5.000";

                        XmlElement misc_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        misc_amount_is_weight.InnerText = "FALSE";

                        XmlElement misc_use_for = documentRecipe.CreateElement("USE_FOR");
                        misc_use_for.InnerText = "Fruit Beer";

                        XmlElement misc_notes = documentRecipe.CreateElement("NOTES");
                        misc_notes.InnerText = "";

                        XmlElement misc_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        misc_display_amount.InnerText = "6.50 oz";

                        XmlElement misc_inventory = documentRecipe.CreateElement("INVENTORY");
                        misc_inventory.InnerText = "0.00 oz";

                        XmlElement misc_display_time = documentRecipe.CreateElement("DISPLAY_TIME");
                        misc_display_time.InnerText = "5.0 min";

                        misc.AppendChild(misc_name);
                        misc.AppendChild(misc_version);
                        misc.AppendChild(misc_type);
                        misc.AppendChild(misc_use);
                        misc.AppendChild(misc_amount);
                        misc.AppendChild(misc_time);
                        misc.AppendChild(misc_amount_is_weight);
                        misc.AppendChild(misc_notes);
                        misc.AppendChild(misc_display_amount);
                        misc.AppendChild(misc_inventory);
                        misc.AppendChild(misc_display_time);

                        miscs.AppendChild(misc);
                    }
                    

                    XmlElement yeasts = documentRecipe.CreateElement("YEASTS");
                    listYeasts listYeast = recipes[i].getYEAST();
                    List<Yeast> YEASTS = new List<Yeast>();
                    YEASTS = listYeast.getYEASTS();
                    for (int j = 0; j < YEASTS.Count; j++)
                    {
                        XmlElement yeast = documentRecipe.CreateElement("YEAST");

                        XmlElement yeast_name = documentRecipe.CreateElement("NAME");
                        yeast_name.InnerText = YEASTS[j].getNAME().ToString();

                        XmlElement yeast_version = documentRecipe.CreateElement("VERSION");
                        yeast_version.InnerText = YEASTS[j].getVERSION().ToString();

                        XmlElement yeast_type = documentRecipe.CreateElement("TYPE");
                        yeast_type.InnerText = YEASTS[j].getTYPE().ToString();

                        XmlElement yeast_form = documentRecipe.CreateElement("FORM");
                        yeast_form.InnerText = YEASTS[j].getFORM().ToString();

                        XmlElement yeast_amount = documentRecipe.CreateElement("AMOUNT");
                        yeast_amount.InnerText = YEASTS[j].getAMOUNT().ToString();

                        XmlElement yeast_amount_is_weight = documentRecipe.CreateElement("AMOUNT_IS_WEIGHT");
                        yeast_amount_is_weight.InnerText = YEASTS[j].getAMOUNT_IS_WEIGHT().ToString();

                        XmlElement yeast_laboratory = documentRecipe.CreateElement("LABORATORY");
                        yeast_laboratory.InnerText = YEASTS[j].getLABORATORY().ToString();

                        XmlElement yeast_product_id = documentRecipe.CreateElement("PRODUCT_ID");
                        yeast_product_id.InnerText = YEASTS[j].getPRODUCT_ID().ToString();

                        XmlElement yeast_min_temperature = documentRecipe.CreateElement("MIN_TEMPERATURE");
                        yeast_min_temperature.InnerText = YEASTS[j].getMIN_TEMPERATURE().ToString();

                        XmlElement yeast_max_temperature = documentRecipe.CreateElement("MAX_TEMPERATURE");
                        yeast_max_temperature.InnerText = YEASTS[j].getMAX_TEMPERATURE().ToString();

                        XmlElement yeast_flocculation = documentRecipe.CreateElement("FLOCCULATION");
                        yeast_flocculation.InnerText = YEASTS[j].getFLOCCULATION().ToString();

                        XmlElement yeast_attenuation = documentRecipe.CreateElement("ATTENUATION");
                        yeast_attenuation.InnerText = YEASTS[j].getATTENUATION().ToString();

                        XmlElement yeast_notes = documentRecipe.CreateElement("NOTES");
                        yeast_notes.InnerText = YEASTS[j].getNOTES().ToString();

                        XmlElement yeast_best_for = documentRecipe.CreateElement("BEST_FOR");
                        yeast_best_for.InnerText = YEASTS[j].getBEST_FOR().ToString();

                        XmlElement yeast_max_reuse = documentRecipe.CreateElement("MAX_REUSE");
                        yeast_max_reuse.InnerText = YEASTS[j].getMAX_REUSE().ToString();

                        XmlElement yeast_times_cultured = documentRecipe.CreateElement("TIMES_CULTURED");
                        yeast_times_cultured.InnerText = YEASTS[j].getTIMES_CULTURED().ToString();

                        XmlElement yeast_add_to_secondary = documentRecipe.CreateElement("ADD_TO_SECONDARY");
                        yeast_add_to_secondary.InnerText = YEASTS[j].getADD_TO_SECONDARY().ToString();

                        XmlElement yeast_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        yeast_display_amount.InnerText = YEASTS[j].getDISPLAY_AMOUNT().ToString();

                        XmlElement yeast_disp_min_temp = documentRecipe.CreateElement("DISP_MIN_TEMP");
                        yeast_disp_min_temp.InnerText = YEASTS[j].getDISP_MIN_TEMP().ToString();

                        XmlElement yeast_disp_max_temp = documentRecipe.CreateElement("DISP_MAX_TEMP");
                        yeast_disp_max_temp.InnerText = YEASTS[j].getDISP_MAX_TEMP().ToString();

                        XmlElement yeast_inventory = documentRecipe.CreateElement("INVENTORY");
                        yeast_inventory.InnerText = YEASTS[j].getINVENTORY().ToString();

                        XmlElement yeast_culture_date = documentRecipe.CreateElement("CULTURE_DATE");
                        yeast_culture_date.InnerText = YEASTS[j].getCULTURE_DATE().ToString();


                        yeast.AppendChild(yeast_name);
                        yeast.AppendChild(yeast_version);
                        yeast.AppendChild(yeast_type);
                        yeast.AppendChild(yeast_form);
                        yeast.AppendChild(yeast_amount);
                        yeast.AppendChild(yeast_amount_is_weight);
                        yeast.AppendChild(yeast_laboratory);
                        yeast.AppendChild(yeast_product_id);
                        yeast.AppendChild(yeast_min_temperature);
                        yeast.AppendChild(yeast_max_temperature);
                        yeast.AppendChild(yeast_flocculation);
                        yeast.AppendChild(yeast_attenuation);
                        yeast.AppendChild(yeast_notes);
                        yeast.AppendChild(yeast_best_for);
                        yeast.AppendChild(yeast_max_reuse);
                        yeast.AppendChild(yeast_times_cultured);
                        yeast.AppendChild(yeast_add_to_secondary);
                        yeast.AppendChild(yeast_display_amount);
                        yeast.AppendChild(yeast_disp_min_temp);
                        yeast.AppendChild(yeast_disp_max_temp);
                        yeast.AppendChild(yeast_inventory);
                        yeast.AppendChild(yeast_culture_date);

                        yeasts.AppendChild(yeast);
                    }

                    XmlElement waters = documentRecipe.CreateElement("WATERS");
                    listWaters listWater = recipes[i].getWATERS();
                    List<Waters> WATER = new List<Waters>();
                    WATER = listWater.getWATERS();
                    for (int j = 0; j < WATER.Count; j++)
                    {
                        XmlElement water = documentRecipe.CreateElement("WATER");

                        XmlElement water_name = documentRecipe.CreateElement("NAME");
                        water_name.InnerText = WATER[j].getNAME().ToString();

                        XmlElement water_version = documentRecipe.CreateElement("VERSION");
                        water_version.InnerText = WATER[j].getVERSION().ToString();

                        XmlElement water_amount = documentRecipe.CreateElement("AMOUNT");
                        water_amount.InnerText = WATER[j].getAMOUNT().ToString();

                        XmlElement water_calcium = documentRecipe.CreateElement("CALCIUM");
                        water_calcium.InnerText = WATER[j].getCALCIUM().ToString();

                        XmlElement water_bicarbonate = documentRecipe.CreateElement("BICARBONATE");
                        water_bicarbonate.InnerText = WATER[j].getBICARBONATE().ToString();

                        XmlElement water_sulfate = documentRecipe.CreateElement("SULFATE");
                        water_sulfate.InnerText = WATER[j].getSULFATE().ToString();

                        XmlElement water_chloride = documentRecipe.CreateElement("CHLORIDE");
                        water_chloride.InnerText = WATER[j].getCHLORIDE().ToString();

                        XmlElement water_sodium = documentRecipe.CreateElement("SODIUM");
                        water_sodium.InnerText = WATER[j].getSODIUM().ToString();

                        XmlElement water_magnesium = documentRecipe.CreateElement("MAGNESIUM");
                        water_magnesium.InnerText = WATER[j].getMAGNESIUM().ToString();

                        XmlElement water_ph = documentRecipe.CreateElement("PH");
                        water_ph.InnerText = WATER[j].getPH().ToString();

                        XmlElement water_notes = documentRecipe.CreateElement("NOTES");
                        water_notes.InnerText = WATER[j].getNOTES().ToString();

                        XmlElement water_display_amount = documentRecipe.CreateElement("DISPLAY_AMOUNT");
                        water_display_amount.InnerText = WATER[j].getDISPLAY_AMOUNT().ToString();

                        water.AppendChild(water_name);
                        water.AppendChild(water_version);
                        water.AppendChild(water_amount);
                        water.AppendChild(water_calcium);
                        water.AppendChild(water_bicarbonate);
                        water.AppendChild(water_sulfate);
                        water.AppendChild(water_chloride);
                        water.AppendChild(water_sodium);
                        water.AppendChild(water_magnesium);
                        water.AppendChild(water_ph);
                        water.AppendChild(water_notes);
                        water.AppendChild(water_display_amount);

                        waters.AppendChild(water);
                    }

                    XmlElement style = documentRecipe.CreateElement("STYLE");
                    Styles STYLE = recipes[i].getSTYLES();
                    //Style
                    XmlElement style_name = documentRecipe.CreateElement("NAME");
                    style_name.InnerText = STYLE.getNAME().ToString();

                    XmlElement style_version = documentRecipe.CreateElement("VERSION");
                    style_version.InnerText = STYLE.getVERSION().ToString();

                    XmlElement style_category = documentRecipe.CreateElement("CATEGORY");
                    style_category.InnerText = STYLE.getCATEGORY().ToString();

                    XmlElement style_category_number = documentRecipe.CreateElement("CATEGORY_NUMBER");
                    style_category_number.InnerText = STYLE.getCATEGORY_NUMBER().ToString();

                    XmlElement style_style_letter = documentRecipe.CreateElement("STYLE_LETTER");
                    style_style_letter.InnerText = STYLE.getSTYLE_LETTER().ToString();

                    XmlElement style_style_guide = documentRecipe.CreateElement("STYLE_GUIDE");
                    style_style_guide.InnerText = STYLE.getSTYLE_GUIDE().ToString();

                    XmlElement style_type = documentRecipe.CreateElement("TYPE");
                    style_type.InnerText = STYLE.getTYPE().ToString();

                    XmlElement style_og_min = documentRecipe.CreateElement("OG_MIN");
                    style_og_min.InnerText = STYLE.getOG_MIN().ToString();

                    XmlElement style_og_max = documentRecipe.CreateElement("OG_MAX");
                    style_og_max.InnerText = STYLE.getOG_MAX().ToString();

                    XmlElement style_fg_min = documentRecipe.CreateElement("FG_MIN");
                    style_fg_min.InnerText = STYLE.getFG_MIN().ToString();

                    XmlElement style_fg_max = documentRecipe.CreateElement("FG_MAX");
                    style_fg_max.InnerText = STYLE.getFG_MAX().ToString();

                    XmlElement style_ibu_min = documentRecipe.CreateElement("IBU_MIN");
                    style_ibu_min.InnerText = STYLE.getIBU_MIN().ToString();

                    XmlElement style_ibu_max = documentRecipe.CreateElement("IBU_MAX");
                    style_ibu_max.InnerText = STYLE.getIBU_MAX().ToString();

                    XmlElement style_color_min = documentRecipe.CreateElement("COLOR_MIN");
                    style_color_min.InnerText = STYLE.getCOLOR_MIN().ToString();

                    XmlElement style_color_max = documentRecipe.CreateElement("COLOR_MAX");
                    style_color_max.InnerText = STYLE.getCOLOR_MAX().ToString();

                    XmlElement style_carb_min = documentRecipe.CreateElement("CARB_MIN");
                    style_carb_min.InnerText = STYLE.getCARB_MIN().ToString();

                    XmlElement style_carb_max = documentRecipe.CreateElement("CARB_MAX");
                    style_carb_max.InnerText = STYLE.getCARB_MAX().ToString();

                    XmlElement style_abv_max = documentRecipe.CreateElement("ABV_MAX");
                    style_abv_max.InnerText = STYLE.getABV_MAX().ToString();

                    XmlElement style_abv_min = documentRecipe.CreateElement("ABV_MIN");
                    style_abv_min.InnerText = STYLE.getABV_MIN().ToString();

                    XmlElement style_notes = documentRecipe.CreateElement("NOTES");
                    style_notes.InnerText = STYLE.getNOTES().ToString();

                    XmlElement style_profile = documentRecipe.CreateElement("PROFILE");
                    style_profile.InnerText = STYLE.getPROFILE().ToString();

                    XmlElement style_ingredients = documentRecipe.CreateElement("INGREDIENTS");
                    style_ingredients.InnerText = STYLE.getINGREDIENTS().ToString();

                    XmlElement style_examples = documentRecipe.CreateElement("EXAMPLES");
                    style_examples.InnerText = STYLE.getEXAMPLES().ToString();

                    XmlElement style_display_og_min = documentRecipe.CreateElement("DISPLAY_OG_MIN");
                    style_display_og_min.InnerText = STYLE.getDISPLAY_OG_MIN().ToString();

                    XmlElement style_display_og_max = documentRecipe.CreateElement("DISPLAY_OG_MAX");
                    style_display_og_max.InnerText = STYLE.getDISPLAY_OG_MAX().ToString();

                    XmlElement style_display_fg_min = documentRecipe.CreateElement("DISPLAY_FG_MIN");
                    style_display_fg_min.InnerText = STYLE.getDISPLAY_FG_MIN().ToString();

                    XmlElement style_display_fg_max = documentRecipe.CreateElement("DISPLAY_FG_MAX");
                    style_display_fg_max.InnerText = STYLE.getDISPLAY_FG_MAX().ToString();

                    XmlElement style_display_color_min = documentRecipe.CreateElement("DISPLAY_COLOR_MIN");
                    style_display_color_min.InnerText = STYLE.getDISPLAY_COLOR_MIN().ToString();

                    XmlElement style_display_color_max = documentRecipe.CreateElement("DISPLAY_COLOR_MAX");
                    style_display_color_min.InnerText = STYLE.getDISPLAY_COLOR_MAX().ToString();

                    XmlElement style_og_range = documentRecipe.CreateElement("OG_RANGE");
                    style_og_range.InnerText = STYLE.getOG_RANGE().ToString();

                    XmlElement style_fg_range = documentRecipe.CreateElement("FG_RANGE");
                    style_fg_range.InnerText = STYLE.getFG_RANGE().ToString();

                    XmlElement style_ibu_range = documentRecipe.CreateElement("IBU_RANGE");
                    style_ibu_range.InnerText = STYLE.getIBU_RANGE().ToString();

                    XmlElement style_carb_range = documentRecipe.CreateElement("CARB_RANGE");
                    style_carb_range.InnerText = STYLE.getCARB_RANGE().ToString();

                    XmlElement style_color_range = documentRecipe.CreateElement("COLOR_RANGE");
                    style_color_range.InnerText = STYLE.getCOLOR_RANGE().ToString();

                    XmlElement style_abv_range = documentRecipe.CreateElement("ABV_RANGE");
                    style_abv_range.InnerText = STYLE.getABV_RANGE().ToString();

                    style.AppendChild(style_name);
                    style.AppendChild(style_version);
                    style.AppendChild(style_category);
                    style.AppendChild(style_category_number);
                    style.AppendChild(style_style_letter);
                    style.AppendChild(style_style_guide);
                    style.AppendChild(style_type);
                    style.AppendChild(style_og_min);
                    style.AppendChild(style_og_max);
                    style.AppendChild(style_fg_min);
                    style.AppendChild(style_fg_max);
                    style.AppendChild(style_ibu_min);
                    style.AppendChild(style_ibu_max);
                    style.AppendChild(style_color_min);
                    style.AppendChild(style_color_max);
                    style.AppendChild(style_carb_min);
                    style.AppendChild(style_carb_max);
                    style.AppendChild(style_abv_max);
                    style.AppendChild(style_abv_min);
                    style.AppendChild(style_notes);
                    style.AppendChild(style_profile);
                    style.AppendChild(style_ingredients);
                    style.AppendChild(style_examples);
                    style.AppendChild(style_display_og_min);
                    style.AppendChild(style_display_og_max);
                    style.AppendChild(style_display_fg_min);
                    style.AppendChild(style_display_fg_max);
                    style.AppendChild(style_display_color_min);
                    style.AppendChild(style_display_color_max);
                    style.AppendChild(style_og_range);
                    style.AppendChild(style_fg_range);
                    style.AppendChild(style_ibu_range);
                    style.AppendChild(style_carb_range);
                    style.AppendChild(style_color_range);
                    style.AppendChild(style_abv_range);

                    XmlElement equipment = documentRecipe.CreateElement("EQUIPMENT");
                    Equipments EQUIPMENT = recipes[i].getEQUIPMENTS();
                    //Equipment
                    XmlElement equipment_name = documentRecipe.CreateElement("NAME");
                    equipment_name.InnerText = EQUIPMENT.getNAME().ToString();

                    XmlElement equipment_version = documentRecipe.CreateElement("VERSION");
                    equipment_version.InnerText = EQUIPMENT.getVERSION().ToString();

                    XmlElement equipment_boil_size = documentRecipe.CreateElement("BOIL_SIZE");
                    equipment_boil_size.InnerText = EQUIPMENT.getBOIL_SIZE().ToString();

                    XmlElement equipment_batch_size = documentRecipe.CreateElement("BATCH_SIZE");
                    equipment_batch_size.InnerText = EQUIPMENT.getBATCH_SIZE().ToString();

                    XmlElement equipment_tun_volume = documentRecipe.CreateElement("TUN_VOLUME");
                    equipment_tun_volume.InnerText = EQUIPMENT.getTUN_VOLUME().ToString();

                    XmlElement equipment_tun_weight = documentRecipe.CreateElement("TUN_WEIGHT");
                    equipment_tun_weight.InnerText = EQUIPMENT.getTUN_WEIGHT().ToString();

                    XmlElement equipment_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    equipment_tun_specific_heat.InnerText = EQUIPMENT.getTUN_SPECIFIC_HEAT().ToString();

                    XmlElement equipment_top_up_water = documentRecipe.CreateElement("TOP_UP_WATER");
                    equipment_top_up_water.InnerText = EQUIPMENT.getTOP_UP_WATER().ToString();

                    XmlElement equipment_trub_chiller_loss = documentRecipe.CreateElement("TRUB_CHILLER_LOSS");
                    equipment_trub_chiller_loss.InnerText = EQUIPMENT.getTRUB_CHILLER_LOSS().ToString();

                    XmlElement equipment_evap_rate = documentRecipe.CreateElement("EVAP_RATE");
                    equipment_evap_rate.InnerText = EQUIPMENT.getEVAP_RATE().ToString();

                    XmlElement equipment_boil_time = documentRecipe.CreateElement("BOIL_TIME");
                    equipment_boil_time.InnerText = EQUIPMENT.getBOIL_TIME().ToString();

                    XmlElement equipment_calc_boil_volume = documentRecipe.CreateElement("CALC_BOIL_VOLUME");
                    equipment_calc_boil_volume.InnerText = EQUIPMENT.getCALC_BOIL_VOLUME().ToString();

                    XmlElement equipment_lauter_deadspace = documentRecipe.CreateElement("LAUTER_DEADSPACE");
                    equipment_lauter_deadspace.InnerText = EQUIPMENT.getLAUTER_DEADSPACE().ToString();

                    XmlElement equipment_top_up_kettle = documentRecipe.CreateElement("TOP_UP_KETTLE");
                    equipment_top_up_kettle.InnerText = EQUIPMENT.getTOP_UP_KETTLE().ToString();

                    XmlElement equipment_hop_utilization = documentRecipe.CreateElement("HOP_UTILIZATION");
                    equipment_hop_utilization.InnerText = EQUIPMENT.getHOP_UTILIZATION().ToString();

                    XmlElement equipment_notes = documentRecipe.CreateElement("NOTES");
                    equipment_notes.InnerText = EQUIPMENT.getNOTES().ToString();

                    XmlElement equipment_display_boil_size = documentRecipe.CreateElement("DISPLAY_BOIL_SIZE");
                    equipment_display_boil_size.InnerText = EQUIPMENT.getDISPLAY_BOIL_SIZE().ToString();

                    XmlElement equipment_display_batch_size = documentRecipe.CreateElement("DISPLAY_BATCH_SIZE");
                    equipment_display_batch_size.InnerText = EQUIPMENT.getDISPLAY_BATCH_SIZE().ToString();

                    XmlElement equipment_display_tun_volume = documentRecipe.CreateElement("DISPLAY_TUN_VOLUME");
                    equipment_display_tun_volume.InnerText = EQUIPMENT.getDISPLAY_TUN_VOLUME().ToString();

                    XmlElement equipment_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    equipment_display_tun_weight.InnerText = EQUIPMENT.getDISPLAY_TUN_WEIGHT().ToString();

                    XmlElement equipment_display_top_up_water = documentRecipe.CreateElement("DISPLAY_TOP_UP_WATER");
                    equipment_display_top_up_water.InnerText = EQUIPMENT.getDISPLAY_TOP_UP_WATER().ToString();

                    XmlElement equipment_display_trub_chiller_loss = documentRecipe.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    equipment_display_trub_chiller_loss.InnerText = EQUIPMENT.getDISPLAY_TRUB_CHILLER_LOSS().ToString();

                    XmlElement equipment_display_lauter_deadspace = documentRecipe.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    equipment_display_lauter_deadspace.InnerText = EQUIPMENT.getDISPLAY_LAUTER_DEADSPACE().ToString();

                    XmlElement equipment_display_top_up_kettle = documentRecipe.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    equipment_display_top_up_kettle.InnerText = EQUIPMENT.getDISPLAY_TOP_UP_KETTLE().ToString();

                    equipment.AppendChild(equipment_name);
                    equipment.AppendChild(equipment_version);
                    equipment.AppendChild(equipment_boil_size);
                    equipment.AppendChild(equipment_batch_size);
                    equipment.AppendChild(equipment_tun_volume);
                    equipment.AppendChild(equipment_tun_weight);
                    equipment.AppendChild(equipment_tun_specific_heat);
                    equipment.AppendChild(equipment_top_up_water);
                    equipment.AppendChild(equipment_trub_chiller_loss);
                    equipment.AppendChild(equipment_evap_rate);
                    equipment.AppendChild(equipment_boil_time);
                    equipment.AppendChild(equipment_calc_boil_volume);
                    equipment.AppendChild(equipment_lauter_deadspace);
                    equipment.AppendChild(equipment_top_up_kettle);
                    equipment.AppendChild(equipment_hop_utilization);
                    equipment.AppendChild(equipment_notes);
                    equipment.AppendChild(equipment_display_boil_size);
                    equipment.AppendChild(equipment_display_batch_size);
                    equipment.AppendChild(equipment_display_tun_volume);
                    equipment.AppendChild(equipment_display_tun_weight);
                    equipment.AppendChild(equipment_display_top_up_water);
                    equipment.AppendChild(equipment_display_trub_chiller_loss);
                    equipment.AppendChild(equipment_display_lauter_deadspace);
                    equipment.AppendChild(equipment_display_top_up_kettle);


                    XmlElement mash = documentRecipe.CreateElement("MASH");
                    Mashs MASH = recipes[i].getMASHS();
                    //Equipment
                    XmlElement mash_name = documentRecipe.CreateElement("NAME");
                    mash_name.InnerText = MASH.getNAME().ToString();

                    XmlElement mash_version = documentRecipe.CreateElement("VERSION");
                    mash_version.InnerText = MASH.getVERSION().ToString();

                    XmlElement mash_grain_temp = documentRecipe.CreateElement("GRAIN_TEMP");
                    mash_grain_temp.InnerText = MASH.getGRAIN_TEMP().ToString();

                    XmlElement mash_tun_temp = documentRecipe.CreateElement("TUN_TEMP");
                    mash_tun_temp.InnerText = MASH.getTUN_TEMP().ToString();

                    XmlElement mash_sparge_temp = documentRecipe.CreateElement("SPARGE_TEMP");
                    mash_sparge_temp.InnerText = MASH.getSPARGE_TEMP().ToString();

                    XmlElement mash_ph = documentRecipe.CreateElement("PH");
                    mash_ph.InnerText = MASH.getPH().ToString();

                    XmlElement mash_tun_weight = documentRecipe.CreateElement("TUN_WEIGHT");
                    mash_tun_weight.InnerText = MASH.getTUN_WEIGHT().ToString();

                    XmlElement mash_tun_specific_heat = documentRecipe.CreateElement("TUN_SPECIFIC_HEAT");
                    mash_tun_specific_heat.InnerText = MASH.getTUN_SPECIFIC_HEAT().ToString();

                    XmlElement mash_equip_adjust = documentRecipe.CreateElement("EQUIP_ADJUST");
                    mash_equip_adjust.InnerText = MASH.getEQUIP_ADJUST().ToString();

                    XmlElement mash_notes = documentRecipe.CreateElement("NOTES");
                    mash_notes.InnerText = MASH.getNOTES().ToString();

                    XmlElement mash_display_grain_temp = documentRecipe.CreateElement("DISPLAY_GRAIN_TEMP");
                    mash_display_grain_temp.InnerText = MASH.getDISPLAY_GRAIN_TEMP().ToString();

                    XmlElement mash_display_tun_temp = documentRecipe.CreateElement("DISPLAY_TUN_TEMP");
                    mash_display_tun_temp.InnerText = MASH.getDISPLAY_TUN_TEMP().ToString();

                    XmlElement mash_display_sparge_temp = documentRecipe.CreateElement("DISPLAY_SPARGE_TEMP");
                    mash_display_sparge_temp.InnerText = MASH.getDISPLAY_SPARGE_TEMP().ToString();

                    XmlElement mash_display_tun_weight = documentRecipe.CreateElement("DISPLAY_TUN_WEIGHT");
                    mash_display_tun_weight.InnerText = MASH.getDISPLAY_TUN_WEIGHT().ToString();

                    XmlElement mash_mash_steps = documentRecipe.CreateElement("MASH_STEPS");
                    listMashStep listMashStep = MASH.getMASH_STEPS();
                    List<Mash_step> MASH_STEP = new List<Mash_step>();
                    MASH_STEP = listMashStep.getMASH_STEP();
                    if (MASH_STEP.Count > 0)
                    {
                        for (int j = 0; j < MASH_STEP.Count; j++)
                        {
                            XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                            mash_step_name.InnerText = MASH_STEP[j].getNAME().ToString();

                            XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                            mash_step_version.InnerText = MASH_STEP[j].getVERSION().ToString();

                            XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                            mash_step_type.InnerText = MASH_STEP[j].getTYPE().ToString();

                            XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = MASH_STEP[j].getINFUSE_AMOUNT().ToString();

                            XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = MASH_STEP[j].getSTEP_TIME().ToString();

                            XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = MASH_STEP[j].getSTEP_TEMP().ToString();

                            XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = MASH_STEP[j].getRAMP_TIME().ToString();

                            XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = MASH_STEP[j].getEND_TEMP().ToString();

                            XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = MASH_STEP[j].getDESCRIPTION().ToString();

                            XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = MASH_STEP[j].getWATER_GRAIN_RATIO().ToString();

                            XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = MASH_STEP[j].getDECOCTION_AMT().ToString();

                            XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = MASH_STEP[j].getINFUSE_TEMP().ToString();

                            XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = MASH_STEP[j].getDISPLAY_STEP_TEMP().ToString();

                            XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = MASH_STEP[j].getDISPLAY_INFUSE_AMT().ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            mash_mash_steps.AppendChild(mash_step);
                        }
                    }
                    else
                    {
                        XmlElement mash_step = documentRecipe.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = documentRecipe.CreateElement("NAME");
                        mash_step_name.InnerText = "Mash In";

                        XmlElement mash_step_version = documentRecipe.CreateElement("VERSION");
                        mash_step_version.InnerText = "1";

                        XmlElement mash_step_type = documentRecipe.CreateElement("TYPE");
                        mash_step_type.InnerText = "Infusion";

                        XmlElement mash_step_infuse_amount = documentRecipe.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = "10.646532";

                        XmlElement mash_step_step_time = documentRecipe.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = "60";

                        XmlElement mash_step_step_temp = documentRecipe.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = "67.77777800";

                        XmlElement mash_step_ramp_time = documentRecipe.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = "2";

                        XmlElement mash_step_end_temp = documentRecipe.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = "67.77777800";

                        XmlElement mash_step_description = documentRecipe.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = "Add 11.25 qt of water at 165.9 F";

                        XmlElement mash_step_water_grain_ratio = documentRecipe.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = "1.25";

                        XmlElement mash_step_decoction_amt = documentRecipe.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = "0.00 qt";

                        XmlElement mash_step_infuse_temp = documentRecipe.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = "165.9 F";

                        XmlElement mash_step_deisplay_step_temp = documentRecipe.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = "DISPLAY_STEP_TEMP";

                        XmlElement mash_step_display_infuse_amt = documentRecipe.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = "11.25 qt";


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_mash_steps.AppendChild(mash_step);
                    }
                    
                    mash.AppendChild(mash_name);
                    mash.AppendChild(mash_version);
                    mash.AppendChild(mash_grain_temp);
                    mash.AppendChild(mash_tun_temp);
                    mash.AppendChild(mash_sparge_temp);
                    mash.AppendChild(mash_ph);
                    mash.AppendChild(mash_tun_weight);
                    mash.AppendChild(mash_tun_specific_heat);
                    mash.AppendChild(mash_equip_adjust);
                    mash.AppendChild(mash_notes);
                    mash.AppendChild(mash_display_grain_temp);
                    mash.AppendChild(mash_display_tun_temp);
                    mash.AppendChild(mash_display_sparge_temp);
                    mash.AppendChild(mash_display_tun_weight);
                    mash.AppendChild(mash_mash_steps);


                    XmlElement notes = documentRecipe.CreateElement("NOTES");
                    notes.InnerText = recipes[i].getNOTES();

                    XmlElement taste_notes = documentRecipe.CreateElement("TASTE_NOTES");
                    taste_notes.InnerText = recipes[i].getTASTE_NOTES();

                    XmlElement taste_rating = documentRecipe.CreateElement("TASTE_RATING");
                    taste_rating.InnerText = recipes[i].getTASTE_RATING().ToString();

                    XmlElement og = documentRecipe.CreateElement("OG");
                    og.InnerText = recipes[i].getOG().ToString();

                    XmlElement fg = documentRecipe.CreateElement("FG");
                    fg.InnerText = recipes[i].getFG().ToString();

                    XmlElement carbonation = documentRecipe.CreateElement("CARBONATION");
                    carbonation.InnerText = recipes[i].getCARBONATION().ToString();

                    XmlElement fermentation_stages = documentRecipe.CreateElement("FERMENTATION_STAGES");
                    fermentation_stages.InnerText = recipes[i].getFERMENTATION_STAGES().ToString();

                    XmlElement primary_age = documentRecipe.CreateElement("PRIMARY_AGE");
                    primary_age.InnerText = recipes[i].getPRIMARY_AGE().ToString();

                    XmlElement primary_temp = documentRecipe.CreateElement("PRIMARY_TEMP");
                    primary_temp.InnerText = recipes[i].getPRIMARY_TEMP().ToString();

                    XmlElement secondary_age = documentRecipe.CreateElement("SECONDARY_AGE");
                    secondary_age.InnerText = recipes[i].getSECONDARY_AGE().ToString();

                    XmlElement secondary_temp = documentRecipe.CreateElement("SECONDARY_TEMP");
                    secondary_temp.InnerText = recipes[i].getSECONDARY_TEMP().ToString();

                    XmlElement tertiary_age = documentRecipe.CreateElement("TERTIARY_AGE");
                    tertiary_age.InnerText = recipes[i].getTERTIARY_AGE().ToString();

                    XmlElement age = documentRecipe.CreateElement("AGE");
                    age.InnerText = recipes[i].getAGE().ToString();

                    XmlElement age_temp = documentRecipe.CreateElement("AGE_TEMP");
                    age_temp.InnerText = recipes[i].getAGE_TEMP().ToString();

                    XmlElement carbonation_used = documentRecipe.CreateElement("CARBONATION_USED");
                    carbonation_used.InnerText = recipes[i].getCARBONATION_USED().ToString();

                    XmlElement date = documentRecipe.CreateElement("DATE");
                    date.InnerText = recipes[i].getDATE().ToString();

                    XmlElement est_og = documentRecipe.CreateElement("EST_OG");
                    est_og.InnerText = recipes[i].getEST_OG().ToString();

                    XmlElement est_fg = documentRecipe.CreateElement("EST_FG");
                    est_fg.InnerText = recipes[i].getEST_FG().ToString();

                    XmlElement est_color = documentRecipe.CreateElement("EST_COLOR");
                    est_color.InnerText = recipes[i].getEST_COLOR().ToString();

                    XmlElement ibu = documentRecipe.CreateElement("IBU");
                    ibu.InnerText = recipes[i].getIBU().ToString();

                    XmlElement ibu_method = documentRecipe.CreateElement("IBU_METHOD");
                    ibu_method.InnerText = recipes[i].getIBU_METHOD().ToString();

                    XmlElement est_abv = documentRecipe.CreateElement("EST_ABV");
                    est_abv.InnerText = recipes[i].getEST_ABV().ToString();

                    XmlElement abv = documentRecipe.CreateElement("ABV");
                    abv.InnerText = recipes[i].getABV().ToString();

                    XmlElement actual_efficiency = documentRecipe.CreateElement("ACTUAL_EFFICIENCY");
                    actual_efficiency.InnerText = recipes[i].getACTUAL_EFFICIENCY().ToString();

                    XmlElement calories = documentRecipe.CreateElement("CALORIES");
                    calories.InnerText = recipes[i].getCALORIES().ToString();

                    XmlElement display_batch_size = documentRecipe.CreateElement("DISPLAY_BATCH_SIZE");
                    display_batch_size.InnerText = recipes[i].getDISPLAY_BATCH_SIZE().ToString();

                    XmlElement display_boil_size = documentRecipe.CreateElement("DISPLAY_BOIL_SIZE");
                    display_boil_size.InnerText = recipes[i].getDISPLAY_BOIL_SIZE().ToString();

                    XmlElement display_og = documentRecipe.CreateElement("DISPLAY_OG");
                    display_og.InnerText = recipes[i].getDISPLAY_OG().ToString();

                    XmlElement display_fg = documentRecipe.CreateElement("DISPLAY_FG");
                    display_fg.InnerText = recipes[i].getDISPLAY_FG().ToString();

                    XmlElement display_primary_temp = documentRecipe.CreateElement("DISPLAY_PRIMARY_TEMP");
                    display_primary_temp.InnerText = recipes[i].getDISPLAY_PRIMARY_TEMP().ToString();

                    XmlElement display_secondary_temp = documentRecipe.CreateElement("DISPLAY_SECONDARY_TEMP");
                    display_secondary_temp.InnerText = recipes[i].getDISPLAY_SECONDARY_TEMP().ToString();

                    XmlElement display_tertiary_temp = documentRecipe.CreateElement("DISPLAY_TERTIARY_TEMP");
                    display_tertiary_temp.InnerText = recipes[i].getDISPLAY_TERTIARY_TEMP().ToString();

                    XmlElement display_age_temp = documentRecipe.CreateElement("DISPLAY_AGE_TEMP");
                    display_age_temp.InnerText = recipes[i].getDISPLAY_AGE_TEMP().ToString();

                    recipe.AppendChild(name);
                    recipe.AppendChild(version);
                    recipe.AppendChild(type);
                    recipe.AppendChild(brewer);
                    recipe.AppendChild(asst_brewer);
                    recipe.AppendChild(batch_size);
                    recipe.AppendChild(boil_size);
                    recipe.AppendChild(boil_time);
                    recipe.AppendChild(efficiency);
                    recipe.AppendChild(hops);
                    recipe.AppendChild(fermentables);
                    recipe.AppendChild(miscs);
                    recipe.AppendChild(yeasts);
                    recipe.AppendChild(waters);
                    recipe.AppendChild(style);
                    recipe.AppendChild(equipment);
                    recipe.AppendChild(mash);
                    recipe.AppendChild(notes);
                    recipe.AppendChild(taste_notes);
                    recipe.AppendChild(taste_rating);
                    recipe.AppendChild(og);
                    recipe.AppendChild(fg);
                    recipe.AppendChild(carbonation);
                    recipe.AppendChild(fermentation_stages);
                    recipe.AppendChild(primary_age);
                    recipe.AppendChild(primary_temp);
                    recipe.AppendChild(secondary_age);
                    recipe.AppendChild(secondary_temp);
                    recipe.AppendChild(tertiary_age);
                    recipe.AppendChild(age);
                    recipe.AppendChild(age_temp);
                    recipe.AppendChild(carbonation_used);
                    recipe.AppendChild(date);
                    recipe.AppendChild(est_og);
                    recipe.AppendChild(est_fg);
                    recipe.AppendChild(est_color);
                    recipe.AppendChild(ibu);
                    recipe.AppendChild(ibu_method);
                    recipe.AppendChild(est_abv);
                    recipe.AppendChild(abv);
                    recipe.AppendChild(actual_efficiency);
                    recipe.AppendChild(calories);
                    recipe.AppendChild(display_batch_size);
                    recipe.AppendChild(display_boil_size);
                    recipe.AppendChild(display_og);
                    recipe.AppendChild(display_fg);
                    recipe.AppendChild(display_primary_temp);
                    recipe.AppendChild(display_secondary_temp);
                    recipe.AppendChild(display_tertiary_temp);
                    recipe.AppendChild(display_age_temp);

                    documentRecipe.DocumentElement.InsertAfter(recipe, documentRecipe.DocumentElement.LastChild);
                    try
                    {
                        fsRecipes = new FileStream(fileRecipes, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentRecipe.Save(fsRecipes);
                    //fsRecipes.Close();
                    fsPath.Close();
                }
            }
            message.title = "Import recipe";
            message.Content = "Import success";
            message.ShowDialog();
            loadRecipes();
        }

        private void btnExportRecipes_Click(object sender, EventArgs e)
        {
            if (txtRecipes.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select recipe";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement recipes = doc.CreateElement("RECIPES");

                    XmlElement recipe = doc.CreateElement("RECIPE");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtRecipes.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement type = doc.CreateElement("TYPE");
                    type.InnerText = "All Grain";

                    XmlElement brewer = doc.CreateElement("BREWER");
                    brewer.InnerText = txtBrewerRecipes.Text;

                    XmlElement asst_brewer = doc.CreateElement("ASST_BREWER");
                    asst_brewer.InnerText = txtAsstBrewerRecipes.Text;

                    XmlElement batch_size = doc.CreateElement("BATCH_SIZE");
                    batch_size.InnerText = txtTargetBatchSizeRecipes.Text.Replace("L", "");

                    XmlElement boil_size = doc.CreateElement("BOIL_SIZE");
                    boil_size.InnerText = txtTargetBoilSizeRecipes.Text.Replace("L", "");

                    XmlElement boil_time = doc.CreateElement("BOIL_TIME");
                    boil_time.InnerText = txtBoilTimeRecipes.Text;

                    XmlElement efficiency = doc.CreateElement("EFFICIENCY");
                    efficiency.InnerText = txtEfficiencyRecipes.Text;

                    //HOPS
                    XmlElement hops = doc.CreateElement("HOPS");
                    for (int i = 0; i < tableViewHopsRecipes.DataRowCount; i++)
                    {
                        XmlElement hop = doc.CreateElement("HOP");

                        XmlElement hop_name = doc.CreateElement("NAME");
                        hop_name.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "notes").ToString();

                        XmlElement hop_version = doc.CreateElement("VERSION");
                        hop_version.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "version").ToString();

                        XmlElement hop_origin = doc.CreateElement("ORIGIN");
                        hop_origin.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "origin").ToString();

                        XmlElement hop_alpha = doc.CreateElement("ALPHA");
                        hop_alpha.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "alpha").ToString();

                        XmlElement hop_amount = doc.CreateElement("AMOUNT");
                        hop_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "amount").ToString();

                        XmlElement hop_use = doc.CreateElement("USE");
                        hop_use.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "use").ToString();

                        XmlElement hop_time = doc.CreateElement("TIME");
                        hop_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "time").ToString();

                        XmlElement hop_notes = doc.CreateElement("NOTES");
                        hop_notes.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "notes").ToString();

                        XmlElement hop_type = doc.CreateElement("TYPE");
                        hop_type.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "type").ToString();

                        XmlElement hop_form = doc.CreateElement("FORM");
                        hop_form.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "form").ToString();

                        XmlElement hop_beta = doc.CreateElement("BETA");
                        hop_beta.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "beta").ToString();

                        XmlElement hop_hsi = doc.CreateElement("HSI");
                        hop_hsi.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "hsi").ToString();

                        XmlElement hop_display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                        hop_display_amount.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_amount").ToString();

                        XmlElement hop_inventory = doc.CreateElement("INVENTORY");
                        hop_inventory.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "inventory").ToString();

                        XmlElement hop_display_time = doc.CreateElement("DISPLAY_TIME");
                        hop_display_time.InnerText = tableViewHopsRecipes.GetRowCellValue(i, "display_time").ToString();

                        hop.AppendChild(hop_name);
                        hop.AppendChild(hop_version);
                        hop.AppendChild(hop_origin);
                        hop.AppendChild(hop_alpha);
                        hop.AppendChild(hop_amount);
                        hop.AppendChild(hop_use);
                        hop.AppendChild(hop_time);
                        hop.AppendChild(hop_notes);
                        hop.AppendChild(hop_type);
                        hop.AppendChild(hop_form);
                        hop.AppendChild(hop_beta);
                        hop.AppendChild(hop_hsi);
                        hop.AppendChild(hop_display_amount);
                        hop.AppendChild(hop_inventory);
                        hop.AppendChild(hop_display_time);

                        hops.AppendChild(hop);
                    }

                    //FERMENTABLE
                    XmlElement fermentables = doc.CreateElement("FERMENTABLES");
                    for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
                    {
                        XmlElement fermentable = doc.CreateElement("FERMENTABLE");

                        XmlElement fermentable_name = doc.CreateElement("NAME");
                        fermentable_name.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "name").ToString();

                        XmlElement fermentable_version = doc.CreateElement("VERSION");
                        fermentable_version.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "version").ToString();

                        XmlElement fermentable_type = doc.CreateElement("TYPE");
                        fermentable_type.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "type").ToString();

                        XmlElement fermentable_amount = doc.CreateElement("AMOUNT");
                        fermentable_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "amount").ToString();

                        XmlElement fermentable_yield = doc.CreateElement("YIELD");
                        fermentable_yield.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "yield").ToString();

                        XmlElement fermentable_color = doc.CreateElement("COLOR");
                        fermentable_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString();

                        XmlElement fermentable_add_after_boil = doc.CreateElement("ADD_AFTER_BOIL");
                        fermentable_add_after_boil.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "add_after_boil").ToString();

                        XmlElement fermentable_origin = doc.CreateElement("ORIGIN");
                        fermentable_origin.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "origin").ToString();

                        XmlElement fermentable_supplier = doc.CreateElement("SUPPLIER");
                        fermentable_supplier.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "supplier").ToString();

                        XmlElement fermentable_notes = doc.CreateElement("NOTES");
                        fermentable_notes.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "notes").ToString();

                        XmlElement fermentable_coarse_fine_diff = doc.CreateElement("COARSE_FINE_DIFF");
                        fermentable_coarse_fine_diff.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "coarse_fine_diff").ToString();

                        XmlElement fermentable_moisture = doc.CreateElement("MOISTURE");
                        fermentable_moisture.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "moisture").ToString();

                        XmlElement fermentable_diastatic_power = doc.CreateElement("DIASTATIC_POWER");
                        fermentable_diastatic_power.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "diastatic_power").ToString();

                        XmlElement fermentable_protein = doc.CreateElement("PROTEIN");
                        fermentable_protein.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "protein").ToString();

                        XmlElement fermentable_max_in_batch = doc.CreateElement("MAX_IN_BATCH");
                        fermentable_max_in_batch.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "max_in_batch").ToString();

                        XmlElement fermentable_recommend_mash = doc.CreateElement("RECOMMEND_MASH");
                        fermentable_recommend_mash.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "recommend_mash").ToString();

                        XmlElement fermentable_ibu_gal_per_lb = doc.CreateElement("IBU_GAL_PER_LB");
                        fermentable_ibu_gal_per_lb.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "ibu_gal_per_lb").ToString();

                        XmlElement fermentable_display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                        fermentable_display_amount.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();

                        XmlElement fermentable_inventory = doc.CreateElement("INVENTORY");
                        fermentable_inventory.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "inventory").ToString();

                        XmlElement fermentable_potential = doc.CreateElement("POTENTIAL");
                        fermentable_potential.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "potential").ToString();

                        XmlElement fermentable_display_color = doc.CreateElement("DISPLAY_COLOR");
                        fermentable_display_color.InnerText = tableViewFermentablesRecipes.GetRowCellValue(i, "display_color").ToString();


                        fermentable.AppendChild(fermentable_name);
                        fermentable.AppendChild(fermentable_version);
                        fermentable.AppendChild(fermentable_type);
                        fermentable.AppendChild(fermentable_amount);
                        fermentable.AppendChild(fermentable_yield);
                        fermentable.AppendChild(fermentable_color);
                        fermentable.AppendChild(fermentable_add_after_boil);
                        fermentable.AppendChild(fermentable_origin);
                        fermentable.AppendChild(fermentable_supplier);
                        fermentable.AppendChild(fermentable_notes);
                        fermentable.AppendChild(fermentable_coarse_fine_diff);
                        fermentable.AppendChild(fermentable_moisture);
                        fermentable.AppendChild(fermentable_diastatic_power);
                        fermentable.AppendChild(fermentable_protein);
                        fermentable.AppendChild(fermentable_max_in_batch);
                        fermentable.AppendChild(fermentable_recommend_mash);
                        fermentable.AppendChild(fermentable_ibu_gal_per_lb);
                        fermentable.AppendChild(fermentable_display_amount);
                        fermentable.AppendChild(fermentable_inventory);
                        fermentable.AppendChild(fermentable_potential);
                        fermentable.AppendChild(fermentable_display_color);
                        fermentables.AppendChild(fermentable);
                    }

                    //MISC
                    XmlElement miscs = doc.CreateElement("MISCS");
                    for (int i = 0; i < tableViewMiscRecipes.DataRowCount; i++)
                    {
                        XmlElement misc = doc.CreateElement("MISC");

                        XmlElement misc_name = doc.CreateElement("NAME");
                        misc_name.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "name").ToString();

                        XmlElement misc_version = doc.CreateElement("VERSION");
                        misc_version.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "version").ToString();

                        XmlElement misc_type = doc.CreateElement("TYPE");
                        misc_type.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "type").ToString();

                        XmlElement misc_use = doc.CreateElement("USE");
                        misc_use.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use").ToString();

                        XmlElement misc_amount = doc.CreateElement("AMOUNT");
                        misc_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount").ToString();

                        XmlElement misc_time = doc.CreateElement("TIME");
                        misc_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "time").ToString();

                        XmlElement misc_amount_is_weight = doc.CreateElement("AMOUNT_IS_WEIGHT");
                        misc_amount_is_weight.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                        XmlElement misc_use_for = doc.CreateElement("USE_FOR");
                        misc_use_for.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "use_for").ToString();

                        XmlElement misc_notes = doc.CreateElement("NOTES");
                        misc_notes.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "notes").ToString();

                        XmlElement misc_display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                        misc_display_amount.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_amount").ToString();

                        XmlElement misc_inventory = doc.CreateElement("INVENTORY");
                        misc_inventory.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "inventory").ToString();

                        XmlElement misc_display_time = doc.CreateElement("DISPLAY_TIME");
                        misc_display_time.InnerText = tableViewMiscRecipes.GetRowCellValue(i, "display_time").ToString();

                        misc.AppendChild(misc_name);
                        misc.AppendChild(misc_version);
                        misc.AppendChild(misc_type);
                        misc.AppendChild(misc_use);
                        misc.AppendChild(misc_amount);
                        misc.AppendChild(misc_time);
                        misc.AppendChild(misc_amount_is_weight);
                        misc.AppendChild(misc_notes);
                        misc.AppendChild(misc_display_amount);
                        misc.AppendChild(misc_inventory);
                        misc.AppendChild(misc_display_time);
                        miscs.AppendChild(misc);
                    }

                    //YEAST
                    XmlElement yeasts = doc.CreateElement("YEASTS");
                    for (int i = 0; i < tableViewYeastRecipes.DataRowCount; i++)
                    {
                        XmlElement yeast = doc.CreateElement("YEAST");

                        XmlElement yeast_name = doc.CreateElement("NAME");
                        yeast_name.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "name").ToString();

                        XmlElement yeast_version = doc.CreateElement("VERSION");
                        yeast_version.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "version").ToString();

                        XmlElement yeast_type = doc.CreateElement("TYPE");
                        yeast_type.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "type").ToString();

                        XmlElement yeast_form = doc.CreateElement("FORM");
                        yeast_form.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "form").ToString();

                        XmlElement yeast_amount = doc.CreateElement("AMOUNT");
                        yeast_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount").ToString();

                        XmlElement yeast_amount_is_weight = doc.CreateElement("AMOUNT_IS_WEIGHT");
                        yeast_amount_is_weight.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "amount_is_weight").ToString();

                        XmlElement yeast_laboratory = doc.CreateElement("LABORATORY");
                        yeast_laboratory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "laboratory").ToString();

                        XmlElement yeast_product_id = doc.CreateElement("PRODUCT_ID");
                        yeast_product_id.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "product_id").ToString();

                        XmlElement yeast_min_temperature = doc.CreateElement("MIN_TEMPERATURE");
                        yeast_min_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "min_temperature").ToString();

                        XmlElement yeast_max_temperature = doc.CreateElement("MAX_TEMPERATURE");
                        yeast_max_temperature.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_temperature").ToString();

                        XmlElement yeast_flocculation = doc.CreateElement("FLOCCULATION");
                        yeast_flocculation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "flocculation").ToString();

                        XmlElement yeast_attenuation = doc.CreateElement("ATTENUATION");
                        yeast_attenuation.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "attenuation").ToString();

                        XmlElement yeast_notes = doc.CreateElement("NOTES");
                        yeast_notes.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "notes").ToString();

                        XmlElement yeast_best_for = doc.CreateElement("BEST_FOR");
                        yeast_best_for.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "best_for").ToString();

                        XmlElement yeast_max_reuse = doc.CreateElement("MAX_REUSE");
                        yeast_max_reuse.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "max_reuse").ToString();

                        XmlElement yeast_times_cultured = doc.CreateElement("TIMES_CULTURED");
                        yeast_times_cultured.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "times_cultured").ToString();

                        XmlElement yeast_add_to_secondary = doc.CreateElement("ADD_TO_SECONDARY");
                        yeast_add_to_secondary.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "add_to_secondary").ToString();

                        XmlElement yeast_display_amount = doc.CreateElement("DISPLAY_AMOUNT");
                        yeast_display_amount.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "display_amount").ToString();

                        XmlElement yeast_disp_min_temp = doc.CreateElement("DISP_MIN_TEMP");
                        yeast_disp_min_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_min_temp").ToString();

                        XmlElement yeast_disp_max_temp = doc.CreateElement("DISP_MAX_TEMP");
                        yeast_disp_max_temp.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "disp_max_temp").ToString();

                        XmlElement yeast_inventory = doc.CreateElement("INVENTORY");
                        yeast_inventory.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "inventory").ToString();

                        XmlElement yeast_culture_date = doc.CreateElement("CULTURE_DATE");
                        yeast_culture_date.InnerText = tableViewYeastRecipes.GetRowCellValue(i, "culture_date").ToString();


                        yeast.AppendChild(yeast_name);
                        yeast.AppendChild(yeast_version);
                        yeast.AppendChild(yeast_type);
                        yeast.AppendChild(yeast_form);
                        yeast.AppendChild(yeast_amount);
                        yeast.AppendChild(yeast_amount_is_weight);
                        yeast.AppendChild(yeast_laboratory);
                        yeast.AppendChild(yeast_product_id);
                        yeast.AppendChild(yeast_min_temperature);
                        yeast.AppendChild(yeast_max_temperature);
                        yeast.AppendChild(yeast_flocculation);
                        yeast.AppendChild(yeast_attenuation);
                        yeast.AppendChild(yeast_notes);
                        yeast.AppendChild(yeast_best_for);
                        yeast.AppendChild(yeast_max_reuse);
                        yeast.AppendChild(yeast_times_cultured);
                        yeast.AppendChild(yeast_add_to_secondary);
                        yeast.AppendChild(yeast_display_amount);
                        yeast.AppendChild(yeast_disp_min_temp);
                        yeast.AppendChild(yeast_disp_max_temp);
                        yeast.AppendChild(yeast_inventory);
                        yeast.AppendChild(yeast_culture_date);

                        yeasts.AppendChild(yeast);
                    }

                    //WATER
                    XmlElement waters = doc.CreateElement("WATERS");

                    //STYLE
                    XmlElement style = doc.CreateElement("STYLE");
                    XmlNode style_root = documentStyle.DocumentElement;
                    XmlNode style_node = style_root.SelectSingleNode("descendant::STYLE[NAME='" + cbbStyleRecipes.Text + "']");
                    string style_name_text = "";
                    string style_version_text = "1";
                    string style_category_text = "";
                    string style_category_number_text = "1";
                    string style_style_letter_text = "";
                    string style_style_guide_text = "";
                    string style_type_text = "";
                    string style_og_min_text = "0.000";
                    string style_og_max_text = "0.000";
                    string style_fg_min_text = "0.000";
                    string style_fg_max_text = "0.000";
                    string style_ibu_min_text = "0.000";
                    string style_ibu_max_text = "0.000";
                    string style_color_min_text = "0.000";
                    string style_color_max_text = "0.000";
                    string style_carb_min_text = "0.000";
                    string style_carb_max_text = "0.000";
                    string style_abv_max_text = "0.000";
                    string style_abv_min_text = "0.000";
                    string style_notes_text = "";
                    string style_profile_text = "";
                    string style_ingredients_text = "";
                    string style_examples_text = "";
                    string style_display_og_min_text = "";
                    string style_display_og_max_text = "";
                    string style_display_fg_min_text = "";
                    string style_display_fg_max_text = "";
                    string style_display_color_min_text = "";
                    string style_display_color_max_text = "";
                    string style_og_range_text = "";
                    string style_fg_range_text = "";
                    string style_ibu_range_text = "";
                    string style_carb_range_text = "";
                    string style_color_range_text = "";
                    string style_abv_range_text = "";
                    if (style_node != null)
                    {
                        foreach (XmlNode nodes in style_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        style_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        style_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY":
                                    {
                                        style_category_text = nodes.InnerText;
                                        break;
                                    }
                                case "CATEGORY_NUMBER":
                                    {
                                        style_category_number_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_LETTER":
                                    {
                                        style_style_letter_text = nodes.InnerText;
                                        break;
                                    }
                                case "STYLE_GUIDE":
                                    {
                                        style_style_guide_text = nodes.InnerText;
                                        break;
                                    }
                                case "TYPE":
                                    {
                                        style_type_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MIN":
                                    {
                                        style_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_MAX":
                                    {
                                        style_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MIN":
                                    {
                                        style_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_MAX":
                                    {
                                        style_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MIN":
                                    {
                                        style_ibu_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_MAX":
                                    {
                                        style_ibu_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MIN":
                                    {
                                        style_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_MAX":
                                    {
                                        style_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MIN":
                                    {
                                        style_carb_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_MAX":
                                    {
                                        style_carb_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MAX":
                                    {
                                        style_abv_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_MIN":
                                    {
                                        style_abv_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        style_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "PROFILE":
                                    {
                                        style_profile_text = nodes.InnerText;
                                        break;
                                    }
                                case "INGREDIENTS":
                                    {
                                        style_ingredients_text = nodes.InnerText;
                                        break;
                                    }
                                case "EXAMPLES":
                                    {
                                        style_examples_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MIN":
                                    {
                                        style_display_og_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_OG_MAX":
                                    {
                                        style_display_og_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MIN":
                                    {
                                        style_display_fg_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_FG_MAX":
                                    {
                                        style_display_fg_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MIN":
                                    {
                                        style_display_color_min_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_COLOR_MAX":
                                    {
                                        style_display_color_max_text = nodes.InnerText;
                                        break;
                                    }
                                case "OG_RANGE":
                                    {
                                        style_og_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "FG_RANGE":
                                    {
                                        style_fg_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "IBU_RANGE":
                                    {
                                        style_ibu_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "CARB_RANGE":
                                    {
                                        style_carb_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "COLOR_RANGE":
                                    {
                                        style_color_range_text = nodes.InnerText;
                                        break;
                                    }
                                case "ABV_RANGE":
                                    {
                                        style_abv_range_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }

                    }
                    XmlElement style_name = doc.CreateElement("NAME");
                    style_name.InnerText = style_name_text;

                    XmlElement style_version = doc.CreateElement("VERSION");
                    style_version.InnerText = style_version_text;

                    XmlElement style_category = doc.CreateElement("CATEGORY");
                    style_category.InnerText = style_category_text;

                    XmlElement style_category_number = doc.CreateElement("CATEGORY_NUMBER");
                    style_category_number.InnerText = style_category_number_text;

                    XmlElement style_style_letter = doc.CreateElement("STYLE_LETTER");
                    style_style_letter.InnerText = style_style_letter_text;

                    XmlElement style_style_guide = doc.CreateElement("STYLE_GUIDE");
                    style_style_guide.InnerText = style_style_guide_text;

                    XmlElement style_type = doc.CreateElement("TYPE");
                    style_type.InnerText = style_type_text;

                    XmlElement style_og_min = doc.CreateElement("OG_MIN");
                    style_og_min.InnerText = style_og_min_text;

                    XmlElement style_og_max = doc.CreateElement("OG_MAX");
                    style_og_max.InnerText = style_og_max_text;

                    XmlElement style_fg_min = doc.CreateElement("FG_MIN");
                    style_fg_min.InnerText = style_fg_min_text;

                    XmlElement style_fg_max = doc.CreateElement("FG_MAX");
                    style_fg_max.InnerText = style_fg_max_text;

                    XmlElement style_ibu_min = doc.CreateElement("IBU_MIN");
                    style_ibu_min.InnerText = style_ibu_min_text;

                    XmlElement style_ibu_max = doc.CreateElement("IBU_MAX");
                    style_ibu_max.InnerText = style_ibu_max_text;

                    XmlElement style_color_min = doc.CreateElement("COLOR_MIN");
                    style_color_min.InnerText = style_color_min_text;

                    XmlElement style_color_max = doc.CreateElement("COLOR_MAX");
                    style_color_max.InnerText = style_color_max_text;

                    XmlElement style_carb_min = doc.CreateElement("CARB_MIN");
                    style_carb_min.InnerText = style_carb_min_text;

                    XmlElement style_carb_max = doc.CreateElement("CARB_MAX");
                    style_carb_max.InnerText = style_carb_max_text;

                    XmlElement style_abv_max = doc.CreateElement("ABV_MAX");
                    style_abv_max.InnerText = style_abv_max_text;

                    XmlElement style_abv_min = doc.CreateElement("ABV_MIN");
                    style_abv_min.InnerText = style_abv_min_text;

                    XmlElement style_notes = doc.CreateElement("NOTES");
                    style_notes.InnerText = style_notes_text;

                    XmlElement style_profile = doc.CreateElement("PROFILE");
                    style_profile.InnerText = style_profile_text;

                    XmlElement style_ingredients = doc.CreateElement("INGREDIENTS");
                    style_ingredients.InnerText = style_ingredients_text;

                    XmlElement style_examples = doc.CreateElement("EXAMPLES");
                    style_examples.InnerText = style_examples_text;

                    XmlElement style_display_og_min = doc.CreateElement("DISPLAY_OG_MIN");
                    style_display_og_min.InnerText = style_display_og_min_text;

                    XmlElement style_display_og_max = doc.CreateElement("DISPLAY_OG_MAX");
                    style_display_og_max.InnerText = style_display_og_max_text;

                    XmlElement style_display_fg_min = doc.CreateElement("DISPLAY_FG_MIN");
                    style_display_fg_min.InnerText = style_display_fg_min_text;

                    XmlElement style_display_fg_max = doc.CreateElement("DISPLAY_FG_MAX");
                    style_display_fg_max.InnerText = style_display_fg_max_text;

                    XmlElement style_display_color_min = doc.CreateElement("DISPLAY_COLOR_MIN");
                    style_display_color_min.InnerText = style_display_color_min_text;

                    XmlElement style_display_color_max = doc.CreateElement("DISPLAY_COLOR_MAX");
                    style_display_color_max.InnerText = style_display_color_max_text;

                    XmlElement style_og_range = doc.CreateElement("OG_RANGE");
                    style_og_range.InnerText = style_og_range_text;

                    XmlElement style_fg_range = doc.CreateElement("FG_RANGE");
                    style_fg_range.InnerText = style_fg_range_text;

                    XmlElement style_ibu_range = doc.CreateElement("IBU_RANGE");
                    style_ibu_range.InnerText = style_ibu_range_text;

                    XmlElement style_carb_range = doc.CreateElement("CARB_RANGE");
                    style_carb_range.InnerText = style_carb_range_text;

                    XmlElement style_color_range = doc.CreateElement("COLOR_RANGE");
                    style_color_range.InnerText = style_color_range_text;

                    XmlElement style_abv_range = doc.CreateElement("ABV_RANGE");
                    style_abv_range.InnerText = style_abv_range_text;

                    style.AppendChild(style_name);
                    style.AppendChild(style_version);
                    style.AppendChild(style_category);
                    style.AppendChild(style_category_number);
                    style.AppendChild(style_style_letter);
                    style.AppendChild(style_style_guide);
                    style.AppendChild(style_type);
                    style.AppendChild(style_og_min);
                    style.AppendChild(style_og_max);
                    style.AppendChild(style_fg_min);
                    style.AppendChild(style_fg_max);
                    style.AppendChild(style_ibu_min);
                    style.AppendChild(style_ibu_max);
                    style.AppendChild(style_color_min);
                    style.AppendChild(style_color_max);
                    style.AppendChild(style_carb_min);
                    style.AppendChild(style_carb_max);
                    style.AppendChild(style_abv_max);
                    style.AppendChild(style_abv_min);
                    style.AppendChild(style_notes);
                    style.AppendChild(style_profile);
                    style.AppendChild(style_ingredients);
                    style.AppendChild(style_examples);
                    style.AppendChild(style_display_og_min);
                    style.AppendChild(style_display_og_max);
                    style.AppendChild(style_display_fg_min);
                    style.AppendChild(style_display_fg_max);
                    style.AppendChild(style_display_color_min);
                    style.AppendChild(style_display_color_max);
                    style.AppendChild(style_og_range);
                    style.AppendChild(style_fg_range);
                    style.AppendChild(style_ibu_range);
                    style.AppendChild(style_carb_range);
                    style.AppendChild(style_color_range);
                    style.AppendChild(style_abv_range);


                    //EQUIPMENT
                    XmlElement equipment = doc.CreateElement("EQUIPMENT");
                    XmlNode equipment_root = documentEquipment.DocumentElement;
                    XmlNode equipment_node = equipment_root.SelectSingleNode("descendant::EQUIPMENT[NAME='" + cbbEquipmentRecipes.Text + "']");
                    string equipment_name_text = "";
                    string equipment_version_text = "1";
                    string equipment_boil_size_text = "0.000";
                    string equipment_batch_size_text = "0.000";
                    string equipment_tun_volume_text = "0.000";
                    string equipment_tun_weight_text = "0.000";
                    string equipment_tun_specific_heat_text = "0.000";
                    string equipment_top_up_water_text = "0.000";
                    string equipment_trub_chiller_loss_text = "0.000";
                    string equipment_evap_rate_text = "0.000";
                    string equipment_boil_time_text = "0.000";
                    string equipment_calc_boil_volume_text = "FALSE";
                    string equipment_lauter_deadspace_text = "0.000";
                    string equipment_top_up_kettle_text = "0.000";
                    string equipment_hop_utilization_text = "0.000";
                    string equipment_notes_text = "";
                    string equipment_display_boil_size_text = "";
                    string equipment_display_batch_size_text = "";
                    string equipment_display_tun_volume_text = "";
                    string equipment_display_tun_weight_text = "";
                    string equipment_display_top_up_water_text = "";
                    string equipment_display_trub_chiller_loss_text = "";
                    string equipment_display_lauter_deadspace_text = "";
                    string equipment_display_top_up_kettle_text = "";

                    if (equipment_node != null)
                    {
                        foreach (XmlNode nodes in equipment_node.ChildNodes)
                        {
                            switch (nodes.Name)
                            {
                                case "NAME":
                                    {
                                        equipment_name_text = nodes.InnerText;
                                        break;
                                    }
                                case "VERSION":
                                    {
                                        equipment_version_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_SIZE":
                                    {
                                        equipment_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "BATCH_SIZE":
                                    {
                                        equipment_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_VOLUME":
                                    {
                                        equipment_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_WEIGHT":
                                    {
                                        equipment_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "TUN_SPECIFIC_HEAT":
                                    {
                                        equipment_tun_specific_heat_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_WATER":
                                    {
                                        equipment_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "TRUB_CHILLER_LOSS":
                                    {
                                        equipment_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "EVAP_RATE":
                                    {
                                        equipment_evap_rate_text = nodes.InnerText;
                                        break;
                                    }
                                case "BOIL_TIME":
                                    {
                                        equipment_boil_time_text = nodes.InnerText;
                                        break;
                                    }
                                case "CALC_BOIL_VOLUME":
                                    {
                                        equipment_calc_boil_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "LAUTER_DEADSPACE":
                                    {
                                        equipment_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "TOP_UP_KETTLE":
                                    {
                                        equipment_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                                case "HOP_UTILIZATION":
                                    {
                                        equipment_hop_utilization_text = nodes.InnerText;
                                        break;
                                    }
                                case "NOTES":
                                    {
                                        equipment_notes_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BOIL_SIZE":
                                    {
                                        equipment_display_boil_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_BATCH_SIZE":
                                    {
                                        equipment_display_batch_size_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_VOLUME":
                                    {
                                        equipment_display_tun_volume_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TUN_WEIGHT":
                                    {
                                        equipment_display_tun_weight_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_WATER":
                                    {
                                        equipment_display_top_up_water_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TRUB_CHILLER_LOSS":
                                    {
                                        equipment_display_trub_chiller_loss_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_LAUTER_DEADSPACE":
                                    {
                                        equipment_display_lauter_deadspace_text = nodes.InnerText;
                                        break;
                                    }
                                case "DISPLAY_TOP_UP_KETTLE":
                                    {
                                        equipment_display_top_up_kettle_text = nodes.InnerText;
                                        break;
                                    }
                            }
                        }
                    }
                    XmlElement equipment_name = doc.CreateElement("NAME");
                    equipment_name.InnerText = equipment_name_text;

                    XmlElement equipment_version = doc.CreateElement("VERSION");
                    equipment_version.InnerText = equipment_version_text;

                    XmlElement equipment_boil_size = doc.CreateElement("BOIL_SIZE");
                    equipment_boil_size.InnerText = equipment_boil_size_text;

                    XmlElement equipment_batch_size = doc.CreateElement("BATCH_SIZE");
                    equipment_batch_size.InnerText = equipment_batch_size_text;

                    XmlElement equipment_tun_volume = doc.CreateElement("TUN_VOLUME");
                    equipment_tun_volume.InnerText = equipment_tun_volume_text;

                    XmlElement equipment_tun_weight = doc.CreateElement("TUN_WEIGHT");
                    equipment_tun_weight.InnerText = equipment_tun_weight_text;

                    XmlElement equipment_tun_specific_heat = doc.CreateElement("TUN_SPECIFIC_HEAT");
                    equipment_tun_specific_heat.InnerText = equipment_tun_specific_heat_text;

                    XmlElement equipment_top_up_water = doc.CreateElement("TOP_UP_WATER");
                    equipment_top_up_water.InnerText = equipment_top_up_water_text;

                    XmlElement equipment_trub_chiller_loss = doc.CreateElement("TRUB_CHILLER_LOSS");
                    equipment_trub_chiller_loss.InnerText = equipment_trub_chiller_loss_text;

                    XmlElement equipment_evap_rate = doc.CreateElement("EVAP_RATE");
                    equipment_evap_rate.InnerText = equipment_evap_rate_text;

                    XmlElement equipment_boil_time = doc.CreateElement("BOIL_TIME");
                    equipment_boil_time.InnerText = equipment_boil_time_text;

                    XmlElement equipment_calc_boil_volume = doc.CreateElement("CALC_BOIL_VOLUME");
                    equipment_calc_boil_volume.InnerText = equipment_calc_boil_volume_text;

                    XmlElement equipment_lauter_deadspace = doc.CreateElement("LAUTER_DEADSPACE");
                    equipment_lauter_deadspace.InnerText = equipment_lauter_deadspace_text;

                    XmlElement equipment_top_up_kettle = doc.CreateElement("TOP_UP_KETTLE");
                    equipment_top_up_kettle.InnerText = equipment_top_up_kettle_text;

                    XmlElement equipment_hop_utilization = doc.CreateElement("HOP_UTILIZATION");
                    equipment_hop_utilization.InnerText = equipment_hop_utilization_text;

                    XmlElement equipment_notes = doc.CreateElement("NOTES");
                    equipment_notes.InnerText = equipment_notes_text;

                    XmlElement equipment_display_boil_size = doc.CreateElement("DISPLAY_BOIL_SIZE");
                    equipment_display_boil_size.InnerText = equipment_display_boil_size_text;

                    XmlElement equipment_display_batch_size = doc.CreateElement("DISPLAY_BATCH_SIZE");
                    equipment_display_batch_size.InnerText = equipment_display_batch_size_text;

                    XmlElement equipment_display_tun_volume = doc.CreateElement("DISPLAY_TUN_VOLUME");
                    equipment_display_tun_volume.InnerText = equipment_display_tun_volume_text;

                    XmlElement equipment_display_tun_weight = doc.CreateElement("DISPLAY_TUN_WEIGHT");
                    equipment_display_tun_weight.InnerText = equipment_display_tun_weight_text;

                    XmlElement equipment_display_top_up_water = doc.CreateElement("DISPLAY_TOP_UP_WATER");
                    equipment_display_top_up_water.InnerText = equipment_display_top_up_water_text;

                    XmlElement equipment_display_trub_chiller_loss = doc.CreateElement("DISPLAY_TRUB_CHILLER_LOSS");
                    equipment_display_trub_chiller_loss.InnerText = equipment_display_trub_chiller_loss_text;

                    XmlElement equipment_display_lauter_deadspace = doc.CreateElement("DISPLAY_LAUTER_DEADSPACE");
                    equipment_display_lauter_deadspace.InnerText = equipment_display_lauter_deadspace_text;

                    XmlElement equipment_display_top_up_kettle = doc.CreateElement("DISPLAY_TOP_UP_KETTLE");
                    equipment_display_top_up_kettle.InnerText = equipment_display_top_up_kettle_text;

                    equipment.AppendChild(equipment_name);
                    equipment.AppendChild(equipment_version);
                    equipment.AppendChild(equipment_boil_size);
                    equipment.AppendChild(equipment_batch_size);
                    equipment.AppendChild(equipment_tun_volume);
                    equipment.AppendChild(equipment_tun_weight);
                    equipment.AppendChild(equipment_tun_specific_heat);
                    equipment.AppendChild(equipment_top_up_water);
                    equipment.AppendChild(equipment_trub_chiller_loss);
                    equipment.AppendChild(equipment_evap_rate);
                    equipment.AppendChild(equipment_boil_time);
                    equipment.AppendChild(equipment_calc_boil_volume);
                    equipment.AppendChild(equipment_lauter_deadspace);
                    equipment.AppendChild(equipment_top_up_kettle);
                    equipment.AppendChild(equipment_hop_utilization);
                    equipment.AppendChild(equipment_notes);
                    equipment.AppendChild(equipment_display_boil_size);
                    equipment.AppendChild(equipment_display_batch_size);
                    equipment.AppendChild(equipment_display_tun_volume);
                    equipment.AppendChild(equipment_display_tun_weight);
                    equipment.AppendChild(equipment_display_top_up_water);
                    equipment.AppendChild(equipment_display_trub_chiller_loss);
                    equipment.AppendChild(equipment_display_lauter_deadspace);
                    equipment.AppendChild(equipment_display_top_up_kettle);


                    //MASH
                    XmlElement mash = doc.CreateElement("MASH");

                    XmlElement mash_name = doc.CreateElement("NAME");
                    mash_name.InnerText = "Single Infusion";

                    XmlElement mash_version = doc.CreateElement("VERSION");
                    mash_version.InnerText = "1";

                    XmlElement mash_grain_temp = doc.CreateElement("GRAIN_TEMP");
                    mash_grain_temp.InnerText = "22.22222200";

                    XmlElement mash_tun_temp = doc.CreateElement("TUN_TEMP");
                    mash_tun_temp.InnerText = "22.22222200";

                    XmlElement mash_sparge_temp = doc.CreateElement("SPARGE_TEMP");
                    mash_sparge_temp.InnerText = "75.55555600";

                    XmlElement mash_ph = doc.CreateElement("PH");
                    mash_ph.InnerText = "5.4";

                    XmlElement mash_tun_weigth = doc.CreateElement("TUN_WEIGHT");
                    mash_tun_weigth.InnerText = "1.81436800";

                    XmlElement mash_tun_specific_heat = doc.CreateElement("TUN_SPECIFIC_HEAT");
                    mash_tun_specific_heat.InnerText = "0.30000000";

                    XmlElement mash_equip_adjust = doc.CreateElement("EQUIP_ADJUST");
                    mash_equip_adjust.InnerText = "FALSE";

                    XmlElement mash_notes = doc.CreateElement("NOTES");
                    mash_notes.InnerText = "";

                    XmlElement mash_display_grain_temp = doc.CreateElement("DISPLAY_GRAIN_TEMP");
                    mash_display_grain_temp.InnerText = "72.0 F";

                    XmlElement mash_display_tun_temp = doc.CreateElement("DISPLAY_TUN_TEMP");
                    mash_display_tun_temp.InnerText = "72.0";

                    XmlElement mash_display_sparge_temp = doc.CreateElement("DISPLAY_SPARGE_TEMP");
                    mash_display_sparge_temp.InnerText = "168.0 F";

                    XmlElement mash_display_tun_weight = doc.CreateElement("DISPLAY_TUN_WEIGHT");
                    mash_display_tun_weight.InnerText = "4.00 lb";

                    XmlElement mash_mash_steps = doc.CreateElement("MASH_STEPS");

                    for (int i = 0; i < tableViewMashRecipes.DataRowCount; i++)
                    {
                        XmlElement mash_step = doc.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = doc.CreateElement("NAME");
                        mash_step_name.InnerText = tableViewMashRecipes.GetRowCellValue(i, "name").ToString();

                        XmlElement mash_step_version = doc.CreateElement("VERSION");
                        mash_step_version.InnerText = tableViewMashRecipes.GetRowCellValue(i, "version").ToString();

                        XmlElement mash_step_type = doc.CreateElement("TYPE");
                        mash_step_type.InnerText = tableViewMashRecipes.GetRowCellValue(i, "type").ToString();

                        XmlElement mash_step_infuse_amount = doc.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_amount").ToString();

                        XmlElement mash_step_step_time = doc.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_time").ToString();

                        XmlElement mash_step_step_temp = doc.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "step_temp").ToString();

                        XmlElement mash_step_ramp_time = doc.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = tableViewMashRecipes.GetRowCellValue(i, "ramp_time").ToString();

                        XmlElement mash_step_end_temp = doc.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "end_temp").ToString();

                        XmlElement mash_step_description = doc.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = tableViewMashRecipes.GetRowCellValue(i, "description").ToString();

                        XmlElement mash_step_water_grain_ratio = doc.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = tableViewMashRecipes.GetRowCellValue(i, "water_grain_ratio").ToString();

                        XmlElement mash_step_decoction_amt = doc.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "decoction_amt").ToString();

                        XmlElement mash_step_infuse_temp = doc.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "infuse_temp").ToString();

                        XmlElement mash_step_deisplay_step_temp = doc.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_step_temp").ToString();

                        XmlElement mash_step_display_infuse_amt = doc.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = tableViewMashRecipes.GetRowCellValue(i, "display_infuse_amt").ToString();


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_mash_steps.AppendChild(mash_step);
                    }
                    mash.AppendChild(mash_mash_steps);

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesRecipes.Text;

                    XmlElement taste_notes = doc.CreateElement("TASTE_NOTES");
                    taste_notes.InnerText = txtTasteNotesRecipes.Text;

                    XmlElement taste_rating = doc.CreateElement("TASTE_RATING");
                    taste_rating.InnerText = txtTasteRatingRecipes.Text;

                    XmlElement og = doc.CreateElement("OG");
                    og.InnerText = lbOGRecipes.Text;

                    XmlElement fg = doc.CreateElement("FG");
                    fg.InnerText = lbFGRecipes.Text;

                    XmlElement carbonation = doc.CreateElement("CARBONATION");
                    carbonation.InnerText = txtCarbonationVolumesRecipes.Text;

                    XmlElement fermentation_stages = doc.CreateElement("FERMENTATION_STAGES");
                    fermentation_stages.InnerText = "2";

                    XmlElement primary_age = doc.CreateElement("PRIMARY_AGE");
                    primary_age.InnerText = txtPrimaryAgeRecipes.Text;

                    XmlElement primary_temp = doc.CreateElement("PRIMARY_TEMP");
                    primary_temp.InnerText = txtPrimaryTempRecipes.Text;

                    XmlElement secondary_age = doc.CreateElement("SECONDARY_AGE");
                    secondary_age.InnerText = txtSecondaryAgeRecipes.Text;

                    XmlElement secondary_temp = doc.CreateElement("SECONDARY_TEMP");
                    secondary_temp.InnerText = txtSecondaryTempRecipes.Text;

                    XmlElement tertiary_age = doc.CreateElement("TERTIARY_AGE");
                    tertiary_age.InnerText = txtTertiaryAgeRecipes.Text;

                    XmlElement age = doc.CreateElement("AGE");
                    age.InnerText = "14.0";

                    XmlElement age_temp = doc.CreateElement("AGE_TEMP");
                    age_temp.InnerText = "11.111";

                    XmlElement carbonation_used = doc.CreateElement("CARBONATION_USED");
                    carbonation_used.InnerText = "12 PSI";

                    XmlElement date = doc.CreateElement("DATE");
                    date.InnerText = cbbdateDateFirstBrewedRecipes.Text;

                    XmlElement est_og = doc.CreateElement("EST_OG");
                    est_og.InnerText = lbOGRecipes.Text;

                    XmlElement est_fg = doc.CreateElement("EST_FG");
                    est_fg.InnerText = lbFGRecipes.Text;

                    XmlElement est_color = doc.CreateElement("EST_COLOR");
                    est_color.InnerText = lbColorRecipes.Text;

                    XmlElement ibu = doc.CreateElement("IBU");
                    ibu.InnerText = lbIBURecipes.Text;

                    XmlElement ibu_method = doc.CreateElement("IBU_METHOD");
                    ibu_method.InnerText = lbBitternessRecipes.Text;

                    XmlElement est_abv = doc.CreateElement("EST_ABV");
                    est_abv.InnerText = lbABVRecipes.Text;

                    XmlElement abv = doc.CreateElement("ABV");
                    abv.InnerText = "5.1 %";

                    XmlElement actual_efficiency = doc.CreateElement("ACTUAL_EFFICIENCY");
                    actual_efficiency.InnerText = "69.7 %";

                    XmlElement calories = doc.CreateElement("CALORIES");
                    calories.InnerText = "242 cal/pint";

                    XmlElement display_batch_size = doc.CreateElement("DISPLAY_BATCH_SIZE");
                    display_batch_size.InnerText = "5.00 gal";

                    XmlElement display_boil_size = doc.CreateElement("DISPLAY_BOIL_SIZE");
                    display_boil_size.InnerText = "5.50 gal";

                    XmlElement display_og = doc.CreateElement("DISPLAY_OG");
                    display_og.InnerText = "1.054 SG";

                    XmlElement display_fg = doc.CreateElement("DISPLAY_FG");
                    display_fg.InnerText = "1.015 SG";

                    XmlElement display_primary_temp = doc.CreateElement("DISPLAY_PRIMARY_TEMP");
                    display_primary_temp.InnerText = "68.0 F";

                    XmlElement display_secondary_temp = doc.CreateElement("DISPLAY_SECONDARY_TEMP");
                    display_secondary_temp.InnerText = "68.0 F";

                    XmlElement display_tertiary_temp = doc.CreateElement("DISPLAY_TERTIARY_TEMP");
                    display_tertiary_temp.InnerText = "68.0 F";

                    XmlElement display_age_temp = doc.CreateElement("DISPLAY_AGE_TEMP");
                    display_age_temp.InnerText = "52.0 F";

                    recipe.AppendChild(name);
                    recipe.AppendChild(version);
                    recipe.AppendChild(type);
                    recipe.AppendChild(brewer);
                    recipe.AppendChild(asst_brewer);
                    recipe.AppendChild(batch_size);
                    recipe.AppendChild(boil_size);
                    recipe.AppendChild(boil_time);
                    recipe.AppendChild(efficiency);
                    recipe.AppendChild(hops);
                    recipe.AppendChild(fermentables);
                    recipe.AppendChild(miscs);
                    recipe.AppendChild(yeasts);
                    recipe.AppendChild(waters);
                    recipe.AppendChild(style);
                    recipe.AppendChild(equipment);
                    recipe.AppendChild(mash);
                    recipe.AppendChild(notes);
                    recipe.AppendChild(taste_notes);
                    recipe.AppendChild(taste_rating);
                    recipe.AppendChild(og);
                    recipe.AppendChild(fg);
                    recipe.AppendChild(carbonation);
                    recipe.AppendChild(fermentation_stages);
                    recipe.AppendChild(primary_age);
                    recipe.AppendChild(primary_temp);
                    recipe.AppendChild(secondary_age);
                    recipe.AppendChild(secondary_temp);
                    recipe.AppendChild(tertiary_age);
                    recipe.AppendChild(age);
                    recipe.AppendChild(age_temp);
                    recipe.AppendChild(carbonation_used);
                    recipe.AppendChild(date);
                    recipe.AppendChild(est_og);
                    recipe.AppendChild(est_fg);
                    recipe.AppendChild(est_color);
                    recipe.AppendChild(ibu);
                    recipe.AppendChild(ibu_method);
                    recipe.AppendChild(est_abv);
                    recipe.AppendChild(abv);
                    recipe.AppendChild(actual_efficiency);
                    recipe.AppendChild(calories);
                    recipe.AppendChild(display_batch_size);
                    recipe.AppendChild(display_boil_size);
                    recipe.AppendChild(display_og);
                    recipe.AppendChild(display_fg);
                    recipe.AppendChild(display_primary_temp);
                    recipe.AppendChild(display_secondary_temp);
                    recipe.AppendChild(display_tertiary_temp);
                    recipe.AppendChild(display_age_temp);

                    recipes.AppendChild(recipe);
                    doc.AppendChild(recipes);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  recipe";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        //Mash
        private void btnSaveMash_Click(object sender, EventArgs e)
        {
            if (txtNameMash.Text == "")
            {
                message.title = "Error";
                message.Content = "Mash name not null";
                message.ShowDialog();
            }
            else
            {
                XmlNode root = documentMash.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::MASH[NAME='" + txtNameMash.Text + "']");
                if (node != null)
                {
                    node.ChildNodes[1].InnerText = "1";
                    node.ChildNodes[2].InnerText = txtInitialGrainTempMash.Text;
                    node.ChildNodes[3].InnerText = txtInitialTunTempMash.Text;
                    node.ChildNodes[4].InnerText = txtSpargeTempMash.Text;
                    node.ChildNodes[5].InnerText = txtSpargePHMash.Text;
                    node.ChildNodes[6].InnerText = "0.00000000";
                    node.ChildNodes[7].InnerText = txtTunSpHeatMash.Text;
                    node.ChildNodes[8].InnerText = "FALSE";
                    node.ChildNodes[9].InnerText = txtNotesMash.Text;
                    node.ChildNodes[10].InnerText = "72.0 F";
                    node.ChildNodes[11].InnerText = "72.0";
                    node.ChildNodes[12].InnerText = "168.0 F";
                    node.ChildNodes[13].InnerText = "0.00 lb";
                    node.ChildNodes[13].RemoveAll();

                    if (tableviewMashStep.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableviewMashStep.DataRowCount; i++)
                        {
                            XmlElement mash_step = documentMash.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentMash.CreateElement("NAME");
                            mash_step_name.InnerText = tableviewMashStep.GetRowCellValue(i, "name").ToString();

                            XmlElement mash_step_version = documentMash.CreateElement("VERSION");
                            mash_step_version.InnerText = tableviewMashStep.GetRowCellValue(i, "version").ToString();

                            XmlElement mash_step_type = documentMash.CreateElement("TYPE");
                            mash_step_type.InnerText = tableviewMashStep.GetRowCellValue(i, "type").ToString();

                            XmlElement mash_step_infuse_amount = documentMash.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = tableviewMashStep.GetRowCellValue(i, "infuse_amount").ToString();

                            XmlElement mash_step_step_time = documentMash.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = tableviewMashStep.GetRowCellValue(i, "step_time").ToString();

                            XmlElement mash_step_step_temp = documentMash.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "step_temp").ToString();

                            XmlElement mash_step_ramp_time = documentMash.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = tableviewMashStep.GetRowCellValue(i, "ramp_time").ToString();

                            XmlElement mash_step_end_temp = documentMash.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "end_temp").ToString();

                            XmlElement mash_step_description = documentMash.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = tableviewMashStep.GetRowCellValue(i, "description").ToString();

                            XmlElement mash_step_water_grain_ratio = documentMash.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = tableviewMashStep.GetRowCellValue(i, "water_grain_ratio").ToString();

                            XmlElement mash_step_decoction_amt = documentMash.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = tableviewMashStep.GetRowCellValue(i, "decoction_amt").ToString();

                            XmlElement mash_step_infuse_temp = documentMash.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "infuse_temp").ToString();

                            XmlElement mash_step_deisplay_step_temp = documentMash.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "display_step_temp").ToString();

                            XmlElement mash_step_display_infuse_amt = documentMash.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = tableviewMashStep.GetRowCellValue(i, "display_infuse_amt").ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            node.ChildNodes[13].AppendChild(mash_step);
                        }
                    }
                    else
                    {
                        XmlElement mash_step = documentMash.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = documentMash.CreateElement("NAME");
                        mash_step_name.InnerText = "Mash Out";

                        XmlElement mash_step_version = documentMash.CreateElement("VERSION");
                        mash_step_version.InnerText = "1";

                        XmlElement mash_step_type = documentMash.CreateElement("TYPE");
                        mash_step_type.InnerText = "Infusion";

                        XmlElement mash_step_infuse_amount = documentMash.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = "6.81378";

                        XmlElement mash_step_step_time = documentMash.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = "10";

                        XmlElement mash_step_step_temp = documentMash.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = "0";

                        XmlElement mash_step_ramp_time = documentMash.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = "2";

                        XmlElement mash_step_end_temp = documentMash.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = "75.55556";

                        XmlElement mash_step_description = documentMash.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = "";

                        XmlElement mash_step_water_grain_ratio = documentMash.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = "2.05";

                        XmlElement mash_step_decoction_amt = documentMash.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = "0.00 qt";

                        XmlElement mash_step_infuse_temp = documentMash.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = "185.9 F";

                        XmlElement mash_step_deisplay_step_temp = documentMash.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = "";

                        XmlElement mash_step_display_infuse_amt = documentMash.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = "7.20 qt";


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        node.ChildNodes[13].AppendChild(mash_step);
                    }

                    try
                    {
                        fsMash = new FileStream(fileMash, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    documentMash.Save(fsMash);
                    message.title = "Update Mash";
                    message.Content = "Update success";
                    message.ShowDialog();
                    //fsMash.Close();
                }
                else
                {
                    XmlElement mash = documentMash.CreateElement("MASH");

                    XmlElement name = documentMash.CreateElement("NAME");
                    name.InnerText = txtNameMash.Text;

                    XmlElement version = documentMash.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement grain_temp = documentMash.CreateElement("GRAIN_TEMP");
                    grain_temp.InnerText = txtInitialGrainTempMash.Text;

                    XmlElement tun_temp = documentMash.CreateElement("TUN_TEMP");
                    tun_temp.InnerText = txtInitialTunTempMash.Text;

                    XmlElement sparge_temp = documentMash.CreateElement("SPARGE_TEMP");
                    sparge_temp.InnerText = txtSpargeTempMash.Text;

                    XmlElement ph = documentMash.CreateElement("PH");
                    ph.InnerText = txtSpargePHMash.Text;

                    XmlElement tun_weight = documentMash.CreateElement("TUN_WEIGHT");
                    tun_weight.InnerText = txtTunMassMash.Text;

                    XmlElement tun_specific_heat = documentMash.CreateElement("TUN_SPECIFIC_HEAT");
                    tun_specific_heat.InnerText = txtTunSpHeatMash.Text;

                    XmlElement equip_adjust = documentMash.CreateElement("EQUIP_ADJUST");
                    equip_adjust.InnerText = "FALSE";

                    XmlElement notes = documentMash.CreateElement("NOTES");
                    notes.InnerText = txtNotesMash.Text;

                    XmlElement display_grain_temp = documentMash.CreateElement("DISPLAY_GRAIN_TEMP");
                    display_grain_temp.InnerText = "72.0 F";

                    XmlElement display_tun_temp = documentMash.CreateElement("DISPLAY_TUN_TEMP");
                    display_tun_temp.InnerText = "72";

                    XmlElement display_sparge_temp = documentMash.CreateElement("DISPLAY_SPARGE_TEMP");
                    display_sparge_temp.InnerText = "168.0 F";

                    XmlElement display_tun_weight = documentMash.CreateElement("DISPLAY_TUN_WEIGHT");
                    display_tun_weight.InnerText = "0.00 lb";

                    XmlElement mash_steps = documentMash.CreateElement("MASH_STEPS");

                    if (tableviewMashStep.DataRowCount > 0)
                    {
                        for (int i = 0; i < tableviewMashStep.DataRowCount; i++)
                        {
                            XmlElement mash_step = documentMash.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentMash.CreateElement("NAME");
                            mash_step_name.InnerText = tableviewMashStep.GetRowCellValue(i, "name").ToString();

                            XmlElement mash_step_version = documentMash.CreateElement("VERSION");
                            mash_step_version.InnerText = "1";

                            XmlElement mash_step_type = documentMash.CreateElement("TYPE");
                            mash_step_type.InnerText = tableviewMashStep.GetRowCellValue(i, "type").ToString();

                            XmlElement mash_step_infuse_amount = documentMash.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = tableviewMashStep.GetRowCellValue(i, "infuse_amount").ToString();

                            XmlElement mash_step_step_time = documentMash.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = tableviewMashStep.GetRowCellValue(i, "step_time").ToString();

                            XmlElement mash_step_step_temp = documentMash.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "step_temp").ToString();

                            XmlElement mash_step_ramp_time = documentMash.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = tableviewMashStep.GetRowCellValue(i, "ramp_time").ToString();

                            XmlElement mash_step_end_temp = documentMash.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "end_temp").ToString();

                            XmlElement mash_step_description = documentMash.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = tableviewMashStep.GetRowCellValue(i, "description").ToString();

                            XmlElement mash_step_water_grain_ratio = documentMash.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = tableviewMashStep.GetRowCellValue(i, "water_grain_ratio").ToString();

                            XmlElement mash_step_decoction_amt = documentMash.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = tableviewMashStep.GetRowCellValue(i, "decoction_amt").ToString();

                            XmlElement mash_step_infuse_temp = documentMash.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "infuse_temp").ToString();

                            XmlElement mash_step_deisplay_step_temp = documentMash.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = tableviewMashStep.GetRowCellValue(i, "display_step_temp").ToString();

                            XmlElement mash_step_display_infuse_amt = documentMash.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = tableviewMashStep.GetRowCellValue(i, "display_infuse_amt").ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            mash_steps.AppendChild(mash_step);
                        }
                    }
                    else
                    {
                        XmlElement mash_step = documentMash.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = documentMash.CreateElement("NAME");
                        mash_step_name.InnerText = "Mash Out";

                        XmlElement mash_step_version = documentMash.CreateElement("VERSION");
                        mash_step_version.InnerText = "1";

                        XmlElement mash_step_type = documentMash.CreateElement("TYPE");
                        mash_step_type.InnerText = "Infusion";

                        XmlElement mash_step_infuse_amount = documentMash.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = "6.81378";

                        XmlElement mash_step_step_time = documentMash.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = "10";

                        XmlElement mash_step_step_temp = documentMash.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = "0";

                        XmlElement mash_step_ramp_time = documentMash.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = "2";

                        XmlElement mash_step_end_temp = documentMash.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = "75.55556";

                        XmlElement mash_step_description = documentMash.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = "";

                        XmlElement mash_step_water_grain_ratio = documentMash.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = "2.05";

                        XmlElement mash_step_decoction_amt = documentMash.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = "0.00 qt";

                        XmlElement mash_step_infuse_temp = documentMash.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = "185.9 F";

                        XmlElement mash_step_deisplay_step_temp = documentMash.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = "";

                        XmlElement mash_step_display_infuse_amt = documentMash.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = "7.20 qt";


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_steps.AppendChild(mash_step);
                    }

                    mash.AppendChild(name);
                    mash.AppendChild(version);
                    mash.AppendChild(grain_temp);
                    mash.AppendChild(tun_temp);
                    mash.AppendChild(sparge_temp);
                    mash.AppendChild(ph);
                    mash.AppendChild(tun_weight);
                    mash.AppendChild(tun_specific_heat);
                    mash.AppendChild(equip_adjust);
                    mash.AppendChild(notes);
                    mash.AppendChild(display_grain_temp);
                    mash.AppendChild(display_tun_temp);
                    mash.AppendChild(display_sparge_temp);
                    mash.AppendChild(display_tun_weight);
                    mash.AppendChild(mash_steps);

                    documentMash.DocumentElement.InsertAfter(mash, documentMash.DocumentElement.LastChild);
                    try
                    {
                        fsMash = new FileStream(fileMash, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
                    }
                    catch (Exception) { }
                    //XmlTextWriter writer = new XmlTextWriter(fsMash, null);
                    //writer.Formatting = Formatting.Indented;
                    documentMash.Save(fsMash);

                    message.title = "Save Mash";
                    message.Content = "Save success";
                    message.ShowDialog();
                    //fsMash.Close();
                }
                loadMashs();
            }
        }

        private void btnDeleteMash_Click(object sender, EventArgs e)
        {
            if (txtNameMash.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select mash";
                message.ShowDialog();
            }
            else
            {

                XmlNode root = documentMash.DocumentElement;
                XmlNode node = root.SelectSingleNode("descendant::MASH[NAME='" + txtNameMash.Text + "']");
                if (node != null)
                {
                    documentMash.DocumentElement.RemoveChild(node);
                }
                try
                {
                    fsMash = new FileStream(fileMash, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                }
                catch (Exception) { }
                documentMash.Save(fsMash);
                message.title = "Delete Mash";
                message.Content = "Delete success";
                message.ShowDialog();
                loadMashs();
                fsMash.Close();
            }
        }

        private void btnNewMash_Click(object sender, EventArgs e)
        {
            txtNameMash.Text = "";
            txtInitialGrainTempMash.Text = "20.000 C";
            txtSpargeTempMash.Text = "74.000 C";
            txtSpargePHMash.Text = "7.000";
            txtNotesMash.Text = "";
            txtInitialTunTempMash.Text = "20.000 C";
            txtTunMassMash.Text = "";
            txtTunSpHeatMash.Text = "";

            DataTable dtMash = new DataTable();
            tablecontrolMashStep.DataSource = dtMash;
            dtMash.Columns.Add("name", typeof(string));
            dtMash.Columns.Add("type", typeof(string));
            dtMash.Columns.Add("infuse_amount", typeof(string));
            dtMash.Columns.Add("infuse_temp", typeof(string));
            dtMash.Columns.Add("step_time", typeof(string));

        }

        private void btnExportMash_Click(object sender, EventArgs e)
        {
            if (txtNameMash.Text == "")
            {
                message.title = "Error";
                message.Content = "Not select mash";
                message.ShowDialog();
            }
            else
            {
                SaveFileDialog export = new SaveFileDialog();
                export.Filter = "Text Files | *.xml";
                export.DefaultExt = ".xml";
                if (export.ShowDialog() == DialogResult.OK)
                {
                    string path = export.FileName;
                    FileStream fsPath = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent = true;

                    XmlDocument doc = new XmlDocument();

                    XmlElement Mashs = doc.CreateElement("MASHS");

                    XmlElement Mash = doc.CreateElement("MASH");

                    XmlElement name = doc.CreateElement("NAME");
                    name.InnerText = txtNameMash.Text;

                    XmlElement version = doc.CreateElement("VERSION");
                    version.InnerText = "1";

                    XmlElement grain_temp = doc.CreateElement("GRAIN_TEMP");
                    grain_temp.InnerText = txtInitialGrainTempMash.Text;

                    XmlElement tun_temp = doc.CreateElement("TUN_TEMP");
                    tun_temp.InnerText = txtInitialTunTempMash.Text;

                    XmlElement sparge_temp = doc.CreateElement("SPARGE_TEMP");
                    sparge_temp.InnerText = txtSpargeTempMash.Text;

                    XmlElement ph = doc.CreateElement("PH");
                    ph.InnerText = txtSpargePHMash.Text;

                    XmlElement tun_weight = doc.CreateElement("TUN_WEIGHT");
                    tun_weight.InnerText = txtTunMassMash.Text;

                    XmlElement tun_specific_heat = doc.CreateElement("TUN_SPECIFIC_HEAT");
                    tun_specific_heat.InnerText = txtTunSpHeatMash.Text;

                    XmlElement equip_adjust = doc.CreateElement("EQUIP_ADJUST");
                    equip_adjust.InnerText = "FALSE";

                    XmlElement notes = doc.CreateElement("NOTES");
                    notes.InnerText = txtNotesMash.Text;

                    XmlElement display_grain_temp = doc.CreateElement("DISPLAY_GRAIN_TEMP");
                    display_grain_temp.InnerText = "72.0 F";

                    XmlElement display_tun_temp = doc.CreateElement("DISPLAY_TUN_TEMP");
                    display_tun_temp.InnerText = "72.0";

                    XmlElement display_sparge_temp = doc.CreateElement("DISPLAY_SPARGE_TEMP");
                    display_sparge_temp.InnerText = "168.0 F";

                    XmlElement display_tun_weight = doc.CreateElement("DISPLAY_TUN_WEIGHT");
                    display_tun_weight.InnerText = "0.00 lb";

                    XmlElement mash_steps = doc.CreateElement("MASH_STEPS");

                    for (int j = 0; j < tableviewMashStep.DataRowCount; j++)
                    {
                        XmlElement mash_step = doc.CreateElement("MASH_STEP");

                        XmlElement mash_step_name = doc.CreateElement("NAME");
                        mash_step_name.InnerText = tableviewMashStep.GetRowCellValue(j, "name").ToString();

                        XmlElement mash_step_version = doc.CreateElement("VERSION");
                        mash_step_version.InnerText = tableviewMashStep.GetRowCellValue(j, "version").ToString();

                        XmlElement mash_step_type = doc.CreateElement("TYPE");
                        mash_step_type.InnerText = tableviewMashStep.GetRowCellValue(j, "type").ToString();

                        XmlElement mash_step_infuse_amount = doc.CreateElement("INFUSE_AMOUNT");
                        mash_step_infuse_amount.InnerText = tableviewMashStep.GetRowCellValue(j, "infuse_amount").ToString();

                        XmlElement mash_step_step_time = doc.CreateElement("STEP_TIME");
                        mash_step_step_time.InnerText = tableviewMashStep.GetRowCellValue(j, "step_time").ToString();

                        XmlElement mash_step_step_temp = doc.CreateElement("STEP_TEMP");
                        mash_step_step_temp.InnerText = tableviewMashStep.GetRowCellValue(j, "step_temp").ToString();

                        XmlElement mash_step_ramp_time = doc.CreateElement("RAMP_TIME");
                        mash_step_ramp_time.InnerText = tableviewMashStep.GetRowCellValue(j, "ramp_time").ToString();

                        XmlElement mash_step_end_temp = doc.CreateElement("END_TEMP");
                        mash_step_end_temp.InnerText = tableviewMashStep.GetRowCellValue(j, "end_temp").ToString();

                        XmlElement mash_step_description = doc.CreateElement("DESCRIPTION");
                        mash_step_description.InnerText = tableviewMashStep.GetRowCellValue(j, "description").ToString();

                        XmlElement mash_step_water_grain_ratio = doc.CreateElement("WATER_GRAIN_RATIO");
                        mash_step_water_grain_ratio.InnerText = tableviewMashStep.GetRowCellValue(j, "water_grain_ratio").ToString();

                        XmlElement mash_step_decoction_amt = doc.CreateElement("DECOCTION_AMT");
                        mash_step_decoction_amt.InnerText = tableviewMashStep.GetRowCellValue(j, "decoction_amt").ToString();

                        XmlElement mash_step_infuse_temp = doc.CreateElement("INFUSE_TEMP");
                        mash_step_infuse_temp.InnerText = tableviewMashStep.GetRowCellValue(j, "infuse_temp").ToString();

                        XmlElement mash_step_deisplay_step_temp = doc.CreateElement("DISPLAY_STEP_TEMP");
                        mash_step_deisplay_step_temp.InnerText = tableviewMashStep.GetRowCellValue(j, "display_step_temp").ToString();

                        XmlElement mash_step_display_infuse_amt = doc.CreateElement("DISPLAY_INFUSE_AMT");
                        mash_step_display_infuse_amt.InnerText = tableviewMashStep.GetRowCellValue(j, "display_infuse_amt").ToString();


                        mash_step.AppendChild(mash_step_name);
                        mash_step.AppendChild(mash_step_version);
                        mash_step.AppendChild(mash_step_type);
                        mash_step.AppendChild(mash_step_infuse_amount);
                        mash_step.AppendChild(mash_step_step_time);
                        mash_step.AppendChild(mash_step_step_temp);
                        mash_step.AppendChild(mash_step_ramp_time);
                        mash_step.AppendChild(mash_step_end_temp);
                        mash_step.AppendChild(mash_step_description);
                        mash_step.AppendChild(mash_step_water_grain_ratio);
                        mash_step.AppendChild(mash_step_decoction_amt);
                        mash_step.AppendChild(mash_step_infuse_temp);
                        mash_step.AppendChild(mash_step_deisplay_step_temp);
                        mash_step.AppendChild(mash_step_display_infuse_amt);

                        mash_steps.AppendChild(mash_step);
                    }

                    Mash.AppendChild(name);
                    Mash.AppendChild(version);
                    Mash.AppendChild(grain_temp);
                    Mash.AppendChild(tun_temp);
                    Mash.AppendChild(sparge_temp);
                    Mash.AppendChild(ph);
                    Mash.AppendChild(tun_weight);
                    Mash.AppendChild(tun_specific_heat);
                    Mash.AppendChild(equip_adjust);
                    Mash.AppendChild(notes);
                    Mash.AppendChild(display_grain_temp);
                    Mash.AppendChild(display_tun_temp);
                    Mash.AppendChild(display_sparge_temp);
                    Mash.AppendChild(display_tun_weight);
                    Mash.AppendChild(mash_steps);

                    Mashs.AppendChild(Mash);
                    doc.AppendChild(Mashs);

                    XmlWriter writer = XmlWriter.Create(fsPath, settings);
                    doc.Save(writer);
                    message.title = "Export  mash";
                    message.Content = "Export success";
                    message.ShowDialog();
                    fsPath.Close();
                }
            }
        }

        private void btnImportMash_Click(object sender, EventArgs e)
        {
            OpenFileDialog import = new OpenFileDialog();
            import.Filter = "Text Files | *.xml";
            import.DefaultExt = ".xml";
            if (import.ShowDialog() == DialogResult.OK)
            {
                string path = import.FileName;
                FileStream fsPath = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                XmlDocument doc = new XmlDocument();
                doc.Load(fsPath);
                List<Mashs> Mashs = new List<Mashs>();
                Mashs = ul.ListMashs(doc);
                for (int i = 0; i < Mashs.Count; i++)
                {
                    try
                    {
                        XmlElement Mash = documentMash.CreateElement("MASH");

                        XmlElement name = documentMash.CreateElement("NAME");
                        name.InnerText = Mashs[i].getNAME().ToString();

                        XmlElement version = documentMash.CreateElement("VERSION");
                        version.InnerText = Mashs[i].getVERSION().ToString();

                        XmlElement grain_temp = documentMash.CreateElement("GRAIN_TEMP");
                        grain_temp.InnerText = Mashs[i].getGRAIN_TEMP().ToString();

                        XmlElement tun_temp = documentMash.CreateElement("TUN_TEMP");
                        tun_temp.InnerText = Mashs[i].getTUN_TEMP().ToString();

                        XmlElement sparge_temp = documentMash.CreateElement("SPARGE_TEMP");
                        sparge_temp.InnerText = Mashs[i].getSPARGE_TEMP().ToString();

                        XmlElement ph = documentMash.CreateElement("PH");
                        ph.InnerText = Mashs[i].getPH().ToString();

                        XmlElement tun_weight = documentMash.CreateElement("TUN_WEIGHT");
                        tun_weight.InnerText = Mashs[i].getTUN_WEIGHT().ToString();

                        XmlElement tun_specific_heat = documentMash.CreateElement("TUN_SPECIFIC_HEAT");
                        tun_specific_heat.InnerText = Mashs[i].getTUN_SPECIFIC_HEAT().ToString();

                        XmlElement equip_adjust = documentMash.CreateElement("EQUIP_ADJUST");
                        equip_adjust.InnerText = Mashs[i].getEQUIP_ADJUST().ToString();

                        XmlElement notes = documentMash.CreateElement("NOTES");
                        notes.InnerText = Mashs[i].getNOTES().ToString();

                        XmlElement display_grain_temp = documentMash.CreateElement("DISPLAY_GRAIN_TEMP");
                        display_grain_temp.InnerText = Mashs[i].getDISPLAY_GRAIN_TEMP().ToString();

                        XmlElement display_tun_temp = documentMash.CreateElement("DISPLAY_TUN_TEMP");
                        display_tun_temp.InnerText = Mashs[i].getDISPLAY_TUN_TEMP().ToString();

                        XmlElement display_sparge_temp = documentMash.CreateElement("DISPLAY_SPARGE_TEMP");
                        display_sparge_temp.InnerText = Mashs[i].getDISPLAY_SPARGE_TEMP().ToString();

                        XmlElement display_tun_weight = documentMash.CreateElement("DISPLAY_TUN_WEIGHT");
                        display_tun_weight.InnerText = Mashs[i].getDISPLAY_TUN_WEIGHT().ToString();

                        XmlElement mash_steps = documentMash.CreateElement("MASH_STEPS");

                        listMashStep listMashStep = Mashs[i].getMASH_STEPS();
                        List<Mash_step> MASH_STEP = new List<Mash_step>();
                        MASH_STEP = listMashStep.getMASH_STEP();
                        for (int j = 0; j < MASH_STEP.Count; j++)
                        {
                            XmlElement mash_step = documentMash.CreateElement("MASH_STEP");

                            XmlElement mash_step_name = documentMash.CreateElement("NAME");
                            mash_step_name.InnerText = MASH_STEP[j].getNAME().ToString();

                            XmlElement mash_step_version = documentMash.CreateElement("VERSION");
                            mash_step_version.InnerText = MASH_STEP[j].getVERSION().ToString();

                            XmlElement mash_step_type = documentMash.CreateElement("TYPE");
                            mash_step_type.InnerText = MASH_STEP[j].getTYPE().ToString();

                            XmlElement mash_step_infuse_amount = documentMash.CreateElement("INFUSE_AMOUNT");
                            mash_step_infuse_amount.InnerText = MASH_STEP[j].getINFUSE_AMOUNT().ToString();

                            XmlElement mash_step_step_time = documentMash.CreateElement("STEP_TIME");
                            mash_step_step_time.InnerText = MASH_STEP[j].getSTEP_TIME().ToString();

                            XmlElement mash_step_step_temp = documentMash.CreateElement("STEP_TEMP");
                            mash_step_step_temp.InnerText = MASH_STEP[j].getSTEP_TEMP().ToString();

                            XmlElement mash_step_ramp_time = documentMash.CreateElement("RAMP_TIME");
                            mash_step_ramp_time.InnerText = MASH_STEP[j].getRAMP_TIME().ToString();

                            XmlElement mash_step_end_temp = documentMash.CreateElement("END_TEMP");
                            mash_step_end_temp.InnerText = MASH_STEP[j].getEND_TEMP().ToString();

                            XmlElement mash_step_description = documentMash.CreateElement("DESCRIPTION");
                            mash_step_description.InnerText = MASH_STEP[j].getDESCRIPTION().ToString();

                            XmlElement mash_step_water_grain_ratio = documentMash.CreateElement("WATER_GRAIN_RATIO");
                            mash_step_water_grain_ratio.InnerText = MASH_STEP[j].getWATER_GRAIN_RATIO().ToString();

                            XmlElement mash_step_decoction_amt = documentMash.CreateElement("DECOCTION_AMT");
                            mash_step_decoction_amt.InnerText = MASH_STEP[j].getDECOCTION_AMT().ToString();

                            XmlElement mash_step_infuse_temp = documentMash.CreateElement("INFUSE_TEMP");
                            mash_step_infuse_temp.InnerText = MASH_STEP[j].getINFUSE_TEMP().ToString();

                            XmlElement mash_step_deisplay_step_temp = documentMash.CreateElement("DISPLAY_STEP_TEMP");
                            mash_step_deisplay_step_temp.InnerText = MASH_STEP[j].getDISPLAY_STEP_TEMP().ToString();

                            XmlElement mash_step_display_infuse_amt = documentMash.CreateElement("DISPLAY_INFUSE_AMT");
                            mash_step_display_infuse_amt.InnerText = MASH_STEP[j].getDISPLAY_INFUSE_AMT().ToString();


                            mash_step.AppendChild(mash_step_name);
                            mash_step.AppendChild(mash_step_version);
                            mash_step.AppendChild(mash_step_type);
                            mash_step.AppendChild(mash_step_infuse_amount);
                            mash_step.AppendChild(mash_step_step_time);
                            mash_step.AppendChild(mash_step_step_temp);
                            mash_step.AppendChild(mash_step_ramp_time);
                            mash_step.AppendChild(mash_step_end_temp);
                            mash_step.AppendChild(mash_step_description);
                            mash_step.AppendChild(mash_step_water_grain_ratio);
                            mash_step.AppendChild(mash_step_decoction_amt);
                            mash_step.AppendChild(mash_step_infuse_temp);
                            mash_step.AppendChild(mash_step_deisplay_step_temp);
                            mash_step.AppendChild(mash_step_display_infuse_amt);

                            mash_steps.AppendChild(mash_step);
                        }

                        Mash.AppendChild(name);
                        Mash.AppendChild(version);
                        Mash.AppendChild(grain_temp);
                        Mash.AppendChild(tun_temp);
                        Mash.AppendChild(sparge_temp);
                        Mash.AppendChild(ph);
                        Mash.AppendChild(tun_weight);
                        Mash.AppendChild(tun_specific_heat);
                        Mash.AppendChild(equip_adjust);
                        Mash.AppendChild(notes);
                        Mash.AppendChild(display_grain_temp);
                        Mash.AppendChild(display_tun_temp);
                        Mash.AppendChild(display_sparge_temp);
                        Mash.AppendChild(display_tun_weight);
                        Mash.AppendChild(mash_steps);

                        documentMash.DocumentElement.InsertAfter(Mash, documentMash.DocumentElement.LastChild);
                        try
                        {
                            fsMash = new FileStream(fileMash, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
                        }
                        catch (Exception) { }
                        documentMash.Save(fsMash);

                        message.title = "Import mash";
                        message.Content = "Import success";
                        message.ShowDialog();
                    }
                    catch (Exception)
                    {
                        message.title = "Error";
                        message.Content = "Xml file error, please try again!";
                        message.ShowDialog();
                    }
                }
                loadMashs();
                fsPath.Close();
            }
        }
        private void tableMash_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                txtNameMash.Text = tableviewMash.GetFocusedDataRow()["name"].ToString();
                txtInitialGrainTempMash.Text = tableviewMash.GetFocusedDataRow()["grain_temp"].ToString();
                txtSpargeTempMash.Text = tableviewMash.GetFocusedDataRow()["sparge_temp"].ToString();
                txtSpargePHMash.Text = tableviewMash.GetFocusedDataRow()["ph"].ToString();
                txtNotesMash.Text = tableviewMash.GetFocusedDataRow()["notes"].ToString();
                txtInitialTunTempMash.Text = tableviewMash.GetFocusedDataRow()["tun_temp"].ToString();
                txtTunMassMash.Text = tableviewMash.GetFocusedDataRow()["tun_weight"].ToString();
                txtTunSpHeatMash.Text = tableviewMash.GetFocusedDataRow()["tun_specific_heat"].ToString();

                listMashStep listMash_step = (listMashStep)tableviewMash.GetFocusedDataRow()["mash_steps"];
                List<Mash_step> mash_step = new List<Mash_step>();
                mash_step = listMash_step.getMASH_STEP();
                tableviewMashStep.GridControl.DataSource = ul.dataTableMash_Step(mash_step);
            }
            catch (Exception) { }
        }

        private void tabcontrolRecipes_MouseClick(object sender, MouseEventArgs e)
        {
           

        }

        //Something

        private void navbarItemFermentables_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            tabcontrolIngredients.SelectedTabPageIndex = 0;
        }

        private void navbarItemHops_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            tabcontrolIngredients.SelectedTabPageIndex = 1;
        }

        private void navbarItemYeast_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            tabcontrolIngredients.SelectedTabPageIndex = 3;
        }

        private void navbarItemMiscellaneous_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            tabcontrolIngredients.SelectedTabPageIndex = 2;
        }

        private void navbarItemMash_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            tabcontrolIngredients.SelectedTabPageIndex = 4;
        }


        //Timer
        private void btnSetTime1_Click(object sender, EventArgs e)
        {
            if (txtTime1.Text == "")
            {
                message.title = "Error";
                message.Content = "Time not null";
                message.ShowDialog();
            }
            else
            {
                int time = Convert.ToInt32(txtTime1.Text);
                int hour = time / 3600;
                int min = (time - (hour * 3600)) / 60;
                int second = time - (hour * 3600 + min * 60);
                btnTimer1.Text = hour + ":" + min + ":" + second;
                hour1 = hour;
                min1 = min;
                second1 = second;
            }
        }
        
        private void btnStart1_Click(object sender, EventArgs e)
        {
            if (txtTime1.Text == "")
            {
                message.title = "Error";
                message.Content = "Time not null";
                message.ShowDialog();
            }
            else
            {
                int time = Convert.ToInt32(txtTime1.Text);
                int hour = time / 3600;
                int min = (time - (hour * 3600)) / 60;
                int second = time - (hour * 3600 + min * 60);
                btnTimer1.Text = hour + ":" + min + ":" + second;
                hour1 = hour;
                min1 = min;
                second1 = second;
                timer1.Enabled = true;
            }
        }

        private void btnStop1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }

        public void timer1_tick(object sender, EventArgs e)
        {
            second1--;
            if (second1 <= 0)
            {
                if (min1 > 0)
                {
                    min1 = min1 - 1;
                    second1 = 60;
                }
                else
                {
                    second1 = 0;
                    timer1.Enabled = false;
                }
                
            }
            if (min1 <= 0)
            {
                if (hour1 > 0)
                {
                    hour1 = hour1 - 1;
                    min1 = 60;
                }
                else
                {
                    min1 = 0;
                }
            }
            if (hour1 == 0 && min1 == 0 && second1 == 0)
            {
                timer1.Enabled = false;
            }
            btnTimer1.Text = hour1 + ":" + min1 + ":" + second1;
        }

        public void timer2_tick(object sender, EventArgs e)
        {
            second2--;
            if (second2 <= 0)
            {
                if (min2 > 0)
                {
                    min2 = min2 - 1;
                    second2 = 60;
                }
                else
                {
                    second1 = 0;
                    timer2.Enabled = false;
                }

            }
            if (min2 <= 0)
            {
                if (hour2 > 0)
                {
                    hour2 = hour2 - 1;
                    min2 = 60;
                }
                else
                {
                    min2 = 0;
                }
            }
            if (hour2 == 0 && min2 == 0 && second2 == 0)
            {
                timer2.Enabled = false;
            }
            btnTimer2.Text = hour2 + ":" + min2 + ":" + second2;
        }

        private void btnSet2_Click(object sender, EventArgs e)
        {
            if (txtTimer2.Text == "")
            {
                message.title = "Error";
                message.Content = "Time not null";
                message.ShowDialog();
            }
            else
            {
                int time = Convert.ToInt32(txtTimer2.Text);
                int hour = time / 3600;
                int min = (time - (hour * 3600)) / 60;
                int second = time - (hour * 3600 + min * 60);
                btnTimer2.Text = hour + ":" + min + ":" + second;
                hour2 = hour;
                min2 = min;
                second2 = second;
                timer2.Enabled = true;
            }
        }

        private void btnStart2_Click(object sender, EventArgs e)
        {
            if (txtTimer2.Text == "")
            {
                message.title = "Error";
                message.Content = "Time not null";
                message.ShowDialog();
            }
            else
            {
                int time = Convert.ToInt32(txtTimer2.Text);
                int hour = time / 3600;
                int min = (time - (hour * 3600)) / 60;
                int second = time - (hour * 3600 + min * 60);
                btnTimer2.Text = hour + ":" + min + ":" + second;
                hour2 = hour;
                min2 = min;
                second2 = second;
                timer2.Enabled = true;
            }
        }

        private void btnStop2_Click(object sender, EventArgs e)
        {
            timer2.Enabled = false;
        }

        private void iExit_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void iNewRecipes_ItemClick(object sender, ItemClickEventArgs e)
        {
            tabcontrolRecipesRight.SelectedTabPageIndex = 0;
            tabcontrolRecipes.SelectedTabPageIndex = 0;
            btnNewRecipes_Click(sender, e);
        }

        private void iRecipes_ItemClick(object sender, ItemClickEventArgs e)
        {
            loadRecipes();
           
            cbbStyleRecipes.Properties.DataSource = ul.dataTableStyles(ul.ListStyles(documentStyle));
            cbbStyleRecipes.Properties.PopulateColumns();
            cbbStyleRecipes.Properties.DisplayMember = "name";
            cbbStyleRecipes.Properties.Columns["version"].Visible = false;
            cbbStyleRecipes.Properties.Columns["category"].Visible = false;
            cbbStyleRecipes.Properties.Columns["category_number"].Visible = false;
            cbbStyleRecipes.Properties.Columns["style_letter"].Visible = false;
            cbbStyleRecipes.Properties.Columns["style_guide"].Visible = false;
            cbbStyleRecipes.Properties.Columns["type"].Visible = false;
            cbbStyleRecipes.Properties.Columns["og_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["og_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["fg_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["fg_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["ibu_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["ibu_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["color_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["color_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["carb_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["carb_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["abv_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["abv_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["notes"].Visible = false;
            cbbStyleRecipes.Properties.Columns["profile"].Visible = false;
            cbbStyleRecipes.Properties.Columns["ingredients"].Visible = false;
            cbbStyleRecipes.Properties.Columns["examples"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_og_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_og_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_fg_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_fg_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_color_min"].Visible = false;
            cbbStyleRecipes.Properties.Columns["display_color_max"].Visible = false;
            cbbStyleRecipes.Properties.Columns["og_range"].Visible = false;
            cbbStyleRecipes.Properties.Columns["fg_range"].Visible = false;
            cbbStyleRecipes.Properties.Columns["ibu_range"].Visible = false;
            cbbStyleRecipes.Properties.Columns["carb_range"].Visible = false;
            cbbStyleRecipes.Properties.Columns["color_range"].Visible = false;
            cbbStyleRecipes.Properties.Columns["abv_range"].Visible = false;
            
            cbbEquipmentRecipes.Properties.DataSource = ul.dataTableEquipments(ul.ListEquipments(documentEquipment));
            cbbEquipmentRecipes.Properties.PopulateColumns();
            cbbEquipmentRecipes.Properties.DisplayMember = "name";
            cbbEquipmentRecipes.Properties.Columns["version"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["boil_size"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["batch_size"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["tun_volume"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["tun_weight"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["tun_specific_head"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["top_up_water"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["trub_chiller_loss"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["evap_rate"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["boil_time"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["calc_boil_volume"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["lauter_deadspace"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["top_up_kettle"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["hop_utilization"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["notes"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_boil_size"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_batch_size"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_tun_volume"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_tun_weight"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_top_up_water"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_trub_chiller_loss"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_lauter_deadspace"].Visible = false;
            cbbEquipmentRecipes.Properties.Columns["display_top_up_kettle"].Visible = false;
           

            tabcontrolRecipesRight.SelectedTabPageIndex = 0;
            tabcontrolRecipes.SelectedTabPageIndex = 0;
            try
            {
                splashScreenManager.CloseWaitForm();
            }
            catch (Exception) { }
        }

        private void iTimer_ItemClick(object sender, ItemClickEventArgs e)
        {
            tabcontrolRecipesRight.SelectedTabPageIndex = 8;
        }

        private void cbbStyleRecipes_EditValueChanged(object sender, EventArgs e)
        {

        }

        private void txtTime1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void textEdit2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void tableFermentablesRecipes_MouseClick(object sender, MouseEventArgs e)
        {
            float batch_size = 0;
            try
            {
                batch_size = float.Parse(txtTargetBatchSizeRecipes.Text.Replace("L",""));
            }
            catch (Exception) { }
            float total = 0F;
            float srm = 0F;
            float x1 = 1.49F;
            float x2 = 0.69F;
            for (int i = 0; i < tableViewFermentablesRecipes.DataRowCount; i++)
            {
                float mcu = 1;
                string amount_display = "";
                float amount_row = 0;
                float color_display = 0;
                try
                {
                    amount_display = tableViewFermentablesRecipes.GetRowCellValue(i, "display_amount").ToString();
                    amount_row = float.Parse(amount_display.Replace("lb", ""));
                }
                catch (Exception) { }
                try
                {
                    color_display = float.Parse(tableViewFermentablesRecipes.GetRowCellValue(i, "color").ToString());
                }
                catch (Exception) { }
                mcu = (amount_row * color_display) / batch_size;
                total = total + mcu;
                
            }
            srm = x1 * (total * x2);
            lbColorRecipes.Text = srm + " SRM";
            float color = srm;
            if (color >= 0 && color < 1)
            {
                pictureRecipe.Image = Properties.Resources.SRM0;
            }
            else if (color >= 1 && color < 2)
            {
                pictureRecipe.Image = Properties.Resources.SRM1;
            }
            else if (color >= 2 && color < 3)
            {
                pictureRecipe.Image = Properties.Resources.SRM2;
            }
            else if (color >= 3 && color < 4)
            {
                pictureRecipe.Image = Properties.Resources.SRM3;
            }
            else if (color >= 4 && color < 5)
            {
                pictureRecipe.Image = Properties.Resources.SRM4;
            }
            else if (color >= 5 && color < 6)
            {
                pictureRecipe.Image = Properties.Resources.SRM5;
            }
            else if (color >= 6 && color < 7)
            {
                pictureRecipe.Image = Properties.Resources.SRM6;
            }
            else if (color >= 7 && color < 8)
            {
                pictureRecipe.Image = Properties.Resources.SRM7;
            }
            else if (color >= 8 && color < 9)
            {
                pictureRecipe.Image = Properties.Resources.SRM8;
            }
            else if (color >= 9 && color < 10)
            {
                pictureRecipe.Image = Properties.Resources.SRM9;
            }
            else if (color >= 10 && color < 11)
            {
                pictureRecipe.Image = Properties.Resources.SRM10;
            }
            else if (color >= 11 && color < 12)
            {
                pictureRecipe.Image = Properties.Resources.SRM11;
            }
            else if (color >= 12 && color < 13)
            {
                pictureRecipe.Image = Properties.Resources.SRM12;
            }
            else if (color >= 13 && color < 14)
            {
                pictureRecipe.Image = Properties.Resources.SRM13;
            }
            else if (color >= 14 && color < 15)
            {
                pictureRecipe.Image = Properties.Resources.SRM14;
            }
            else if (color >= 15 && color < 16)
            {
                pictureRecipe.Image = Properties.Resources.SRM15;
            }
            else if (color >= 16 && color < 17)
            {
                pictureRecipe.Image = Properties.Resources.SRM16;
            }
            else if (color >= 17 && color < 18)
            {
                pictureRecipe.Image = Properties.Resources.SRM17;
            }
            else if (color >= 18 && color < 19)
            {
                pictureRecipe.Image = Properties.Resources.SRM18;
            }
            else if (color >= 19 && color < 20)
            {
                pictureRecipe.Image = Properties.Resources.SRM19;
            }
            else if (color >= 20 && color < 21)
            {
                pictureRecipe.Image = Properties.Resources.SRM20;
            }
            else if (color >= 21 && color < 22)
            {
                pictureRecipe.Image = Properties.Resources.SRM21;
            }
            else if (color >= 22 && color < 23)
            {
                pictureRecipe.Image = Properties.Resources.SRM22;
            }
            else if (color >= 23 && color < 24)
            {
                pictureRecipe.Image = Properties.Resources.SRM23;
            }
            else if (color >= 24 && color < 25)
            {
                pictureRecipe.Image = Properties.Resources.SRM24;
            }
            else if (color >= 25 && color < 26)
            {
                pictureRecipe.Image = Properties.Resources.SRM25;
            }
            else if (color >= 26 && color < 27)
            {
                pictureRecipe.Image = Properties.Resources.SRM26;
            }
            else if (color >= 27 && color < 28)
            {
                pictureRecipe.Image = Properties.Resources.SRM27;
            }
            else if (color >= 28 && color < 29)
            {
                pictureRecipe.Image = Properties.Resources.SRM28;
            }
            else if (color >= 29 && color < 30)
            {
                pictureRecipe.Image = Properties.Resources.SRM29;
            }
            else if (color >= 30 && color < 31)
            {
                pictureRecipe.Image = Properties.Resources.SRM30;
            }
            else if (color >= 31 && color < 32)
            {
                pictureRecipe.Image = Properties.Resources.SRM31;
            }
            else if (color >= 32 && color < 33)
            {
                pictureRecipe.Image = Properties.Resources.SRM32;
            }
            else if (color >= 33 && color < 34)
            {
                pictureRecipe.Image = Properties.Resources.SRM33;
            }
            else if (color >= 34 && color < 35)
            {
                pictureRecipe.Image = Properties.Resources.SRM34;
            }
            else if (color >= 35 && color < 36)
            {
                pictureRecipe.Image = Properties.Resources.SRM35;
            }
            else if (color >= 36)
            {
                pictureRecipe.Image = Properties.Resources.SRM36;
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                cbbStyleRecipes.Properties.DataSource = ul.dataTableStyles(ul.ListStyles(documentStyle));
                cbbStyleRecipes.Properties.PopulateColumns();
                cbbStyleRecipes.Properties.DisplayMember = "name";
                cbbStyleRecipes.Properties.Columns["version"].Visible = false;
                cbbStyleRecipes.Properties.Columns["category"].Visible = false;
                cbbStyleRecipes.Properties.Columns["category_number"].Visible = false;
                cbbStyleRecipes.Properties.Columns["style_letter"].Visible = false;
                cbbStyleRecipes.Properties.Columns["style_guide"].Visible = false;
                cbbStyleRecipes.Properties.Columns["type"].Visible = false;
                cbbStyleRecipes.Properties.Columns["og_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["og_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["fg_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["fg_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["ibu_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["ibu_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["color_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["color_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["carb_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["carb_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["abv_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["abv_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["notes"].Visible = false;
                cbbStyleRecipes.Properties.Columns["profile"].Visible = false;
                cbbStyleRecipes.Properties.Columns["ingredients"].Visible = false;
                cbbStyleRecipes.Properties.Columns["examples"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_og_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_og_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_fg_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_fg_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_color_min"].Visible = false;
                cbbStyleRecipes.Properties.Columns["display_color_max"].Visible = false;
                cbbStyleRecipes.Properties.Columns["og_range"].Visible = false;
                cbbStyleRecipes.Properties.Columns["fg_range"].Visible = false;
                cbbStyleRecipes.Properties.Columns["ibu_range"].Visible = false;
                cbbStyleRecipes.Properties.Columns["carb_range"].Visible = false;
                cbbStyleRecipes.Properties.Columns["color_range"].Visible = false;
                cbbStyleRecipes.Properties.Columns["abv_range"].Visible = false;

                cbbEquipmentRecipes.Properties.DataSource = ul.dataTableEquipments(ul.ListEquipments(documentEquipment));
                cbbEquipmentRecipes.Properties.PopulateColumns();
                cbbEquipmentRecipes.Properties.DisplayMember = "name";
                cbbEquipmentRecipes.Properties.Columns["version"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["boil_size"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["batch_size"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["tun_volume"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["tun_weight"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["tun_specific_head"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["top_up_water"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["trub_chiller_loss"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["evap_rate"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["boil_time"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["calc_boil_volume"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["lauter_deadspace"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["top_up_kettle"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["hop_utilization"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["notes"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_boil_size"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_batch_size"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_tun_volume"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_tun_weight"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_top_up_water"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_trub_chiller_loss"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_lauter_deadspace"].Visible = false;
                cbbEquipmentRecipes.Properties.Columns["display_top_up_kettle"].Visible = false;
            }
            catch (Exception) { }
        }

    }
}